问题
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