【发布时间】:2020-05-27 06:36:27
【问题描述】:
我是 Kotlin 的新手,也是 StackOverflow 的新手。这是我的第一个问题。
我正在尝试使用 Kotlin 检索和解析存储在 Google Firebase 存储中的元数据。我已成功检索并显示该文件,并且能够使用 val valName = referenceName.metadata 获取对元数据的引用。此时,我想检索存储在该 val 中的自定义元数据并将其解析为字符串。使用 toString() 打印元数据的内容会将 com.google.android.gms.tasks.taskId 返回到控制台。
到目前为止,我已经访问了这些文档并将它们用于我的很多项目,它们位于: https://firebase.google.com/docs/storage/android/file-metadata,但我不知道下一步该做什么。
感谢您的帮助!
我的代码:
// create an instance of the firebase storage
val storage = FirebaseStorage.getInstance()
// create a reference to storage
val storageRef = storage.reference
// create a reference to the featured content image
val filmRef = storageRef.child("featured/film.jpg")
// place the image metadata in a val - this appears to be working
val filmMeta = filmRef.metadata
// parse metadata to a string
// ****** what to do next? ********
val filmId = filmMeta.customMetadata("id") // <--- this does not work
【问题讨论】:
标签: android firebase kotlin metadata