Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Cloud Storage download url vs path

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 ?

like image 347
user1997296 Avatar asked Sep 10 '18 06:09

user1997296


1 Answers

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

like image 187
Frank van Puffelen Avatar answered Oct 20 '22 20:10

Frank van Puffelen