Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate public url for a file in firebase storage?

Is there any way to generate a public url for a pdf file from firebase storage. The url it gives me right now is this

But we can see this contains a token and this means there is some session/authentication involved.

like image 936
Susheel Tickoo Avatar asked Jun 23 '16 15:06

Susheel Tickoo


People also ask

How do I get Firebase storage public URL?

const publicUrl = format(`https://storage.googleapis.com/${bucket.name}/${blob.name}`); res. status(200). send(publicUrl); });

How can I get download URL from Firebase storage react?

To generate a new Download URL, you need to call the getDownloadURL method on a reference: import storage from '@react-native-firebase/storage'; const url = await storage(). ref('images/profile-1. png').

How do I find the path of a file in Firebase storage?

If you want the file path on firebase storage to access it via storage reference and not URL, you can use taskSnapshot. getStorage().


2 Answers

The token is not an authentication token, nor is it for any session management, it's simply for obfuscation. All these URLs are public, and can be revoked and new tokens generated through the console.

like image 156
Simon Pickup Avatar answered Sep 21 '22 10:09

Simon Pickup


You can delete the token, still get access to the file.

https://firebasestorage.googleapis.com/v0/b/techmlearnings.appspot.com/o/pdfs%2FUMLNotationSummary.pdf?alt=media

I don't know why if I delete "alt=media", it doesn't work

like image 21
Mike Yang Avatar answered Sep 18 '22 10:09

Mike Yang