Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the url of uploaded file, firebase storage + python

I was wondering how could I get the url from the file I am uploading to the firebase storage? Here is my code:

    import firebase_admin
from firebase_admin import credentials, firestore, storage

cred=credentials.Certificate('/serviceAccountKey.json')
firebase_admin.initialize_app(cred, {
    'storageBucket': <my_bucket_name>
})
db = firestore.client()

bucket = storage.bucket()
blob = bucket.blob('image.jpg')
blob.upload_from_filename('/image.jpg')

#here I'd like to have url of file I uploaded
print(blob.<url>)

Thanks in advance.

like image 580
dolphin Avatar asked Sep 21 '18 21:09

dolphin


1 Answers

You should use the following code:

blob.upload_from_filename(BLOB_PATH)
blob.make_public()
print(blob.public_url)
like image 186
Yan Avatar answered Sep 22 '22 12:09

Yan