Firebase Python Unggah Penyimpanan
import firebase_admin
from firebase_admin import credentials
from firebase_admin import storage
# Import UUID4 to create token
from uuid import uuid4
cred = credentials.Certificate("path/to/your/service_account.json")
default_app = firebase_admin.initialize_app(cred, {
'storageBucket': '<BUCKET_NAME>.appspot.com'
})
bucket = storage.bucket()
blob = bucket.blob(img_src)
# Create new token
new_token = uuid4()
# Create new dictionary with the metadata
metadata = {"firebaseStorageDownloadTokens": new_token}
# Set metadata to blob
blob.metadata = metadata
# Upload file
blob.upload_from_filename(filename=img_path, content_type='image/png')
Fine Frog