Firebase Cloud Storage download url vs path

懵懂的女人 提交于 2020-05-12 02:24:11

问题


I'm new to firebase storage and wants to know what is the best practice. I want to upload image to firebase cloud storage and was returned a download url which I then stored to firestore. Is the download url permanent? Other users will read from the firestore to get the url to download the image.

But when I want to delete the image from CloudStorage, I only have the download url but not the file path. So do I delete it ?

If I store the file path instead, how to get the download url ?


回答1:


Is the download url permanent?

The download URL will work until you revoke it.

I only have the download url but not the file path. So do I delete it?

You can get a StorageReference from a download URL by calling FirebaseStorage.getReferenceFromUrl() (or the equivalent for your platform).

If I store the file path instead, how to get the download url?

You can create a StorageReference for the path with FirebaseStorage.getReference(), and then call StorageReference.getDownloadUrl().



来源:https://stackoverflow.com/questions/52252520/firebase-cloud-storage-download-url-vs-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!