6
votes

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

1 Answers

6
votes

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().