我有我的Firebase图像的下载URL,我想将它们转换为对云中图像的引用.有干净的方法吗



最终目标是删除那些图像,如果这很重要的话,我在Firestore中的图像文件夹中有一个StorageReference,位于同一范围内。

以下是代码片段:

private val images = ArrayList<MyImage>()
private val storageRef = Firebase.storage.reference
.child("images")
fun delete(position: Int): Boolean {
val toDelete = images[position].url

// And then what?
return true
}

MyImage对象只包含图像的位图、用户生成的标题和下载url。

如何获取对该文件的引用并告诉Firestore将其删除?

您可以使用storage.refFromUrl((将下载URL转换为引用。

在任何情况下,只需将文件的路径与下载URL一起存储在存储器中就更容易了,这样更容易使用。

最新更新