【发布时间】:2021-10-06 16:51:26
【问题描述】:
所以我尝试按照 youtube 上有关 Firebase 存储的教程进行操作,并找到了以下代码:
val filePathAndName="product_images/"+""+timeStamp
val storageReference=FirebaseStorage.getInstance().getReference(filePathAndName)
但上面的代码在教程中使用了 Java,我将其更改为 Kotlin 语法并尝试运行该应用程序,它可以工作。
阅读有关 Firebase 存储的文档后,我发现:
// Create a child reference
// imagesRef now points to "images"
var imagesRef: StorageReference? = storageRef.child("images")
// Child references can also take paths
// spaceRef now points to "images/space.jpg
// imagesRef still points to "images"
var spaceRef = storageRef.child("images/space.jpg")
那么声明引用的正确方法是什么?而filePathAndName对getReference(filePathAndName)的作用是什么?它在 Kotlin 语法中是否具有与 child 相同的功能?
【问题讨论】:
标签: android firebase kotlin firebase-storage