Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

firebase python upload storage

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')
Comment

PREVIOUS NEXT
Code Example
Python :: how to split a string from the beginning to a specific character in python 
Python :: dataframe plot distribution of dates 
Python :: default style matplotlib python 
Python :: python requests force ipv4 
Python :: overlapping date matplotlib 
Python :: how to clear an array python 
Python :: numpy distance between two points 
Python :: pd.merge left join 
Python :: backup django db from one database to another 
Python :: python make button do more than one command 
Python :: binning dat adataframe 
Python :: somma in python 
Python :: get all paragraph tags beautifulsoup 
Python :: how to write in google chrome console in python 
Python :: compute mfcc python 
Python :: python create tuple from input 
Python :: dataframe groupby to dictionary 
Python :: keras auc without tf.metrics.auc 
Python :: python read text file into a list 
Python :: numpy take out elements equal to zero 
Python :: python round number numpy 
Python :: remove nan particular column pandas 
Python :: Slicing lexicographically pandas 
Python :: create additional rows for missing dates pandas 
Python :: min max scaling pandas 
Python :: np array describe 
Python :: Python program to check leap year or not? 
Python :: python round up 
Python :: python import specific excel sheet 
Python :: python list inversion 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =