I successfully uploaded file to firebase storage using firebase_admin
like this:
from firebase_admin import db
from firebase_admin import credentials
from firebase_admin import storage
from uuid import uuid4
cred = credentials.Certificate('key.json')
firebase_admin.initialize_app(cred, {
'databaseURL' : 'https:url.firebaseio.com/', 'storageBucket': 'bucket.appspot.com'
})
bucket = storage.bucket()
blob = bucket.blob("myfile.txt")
new_token = uuid4()
metadata = {"firebaseStorageDownloadTokens": new_token}
blob.metadata = metadata
blob.download_from_filename(filename="myfile.txt")
But my issue is I don't know how to download file from firebase storage using firebase_admin module. Please tell me a demo code how can I download that file from firebase storage using firebase_admin
Did you find the solution?. I'm trying to download an image. I'm able to write the bytes to a txt file. However, i need to download url or the image.
from firebase_admin import credentials, initialize_app, storage
cred = credentials.Certificate(r"credential_location.JSON")
initialize_app(cred, {'storageBucket': 'xxxxxxxx.appspot.com'})
source_blob_name = "pic5.jpg"
bucket_name = "xxxxxxxxx.appspot.com"
#The path to which the file should be downloaded
destination_file_name = r"localpath\file.txt"
bucket = storage.bucket()
blob = bucket.blob(source_blob_name)
blob.download_to_filename(destination_file_name)
from firebase_admin import credentials, initialize_app, storage
cred = credentials.Certificate(r"credential_location.JSON")
initialize_app(cred, {'storageBucket': 'xxxxxxxx.appspot.com'})
source_blob_name = "pic5.jpg"
bucket_name = "xxxxxxxxx.appspot.com"
#The path to which the file should be downloaded
destination_file_name = r"localpath\file.txt"
bucket = storage.bucket()
blob = bucket.blob(source_blob_name)
blob.download_to_filename(destination_file_name)
just change the extension to.jpg and it will work, destination_file_name = r"localpath\file.jpg"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.