Skip to content

Instantly share code, notes, and snippets.

@rg3915
Created March 18, 2020 04:18
Show Gist options
  • Save rg3915/072cb99dc50445068e142c7fba878a9d to your computer and use it in GitHub Desktop.
Save rg3915/072cb99dc50445068e142c7fba878a9d to your computer and use it in GitHub Desktop.
upload file to firebase with python
'''
If you need upload file to Firebase with Python, use pyrebase.
https://github.com/thisbejim/Pyrebase
https://www.youtube.com/watch?v=I1eskLk0exg
'''
import pyrebase
# Your credentials after create a app web project.
config = {
"apiKey": "your_apiKey",
"authDomain": "your_authDomain",
"databaseURL": "your_databaseURL",
"projectId": "your_projectId",
"storageBucket": "your_storageBucket",
"messagingSenderId": "your_messagingSenderId",
"appId": "your_appId",
"measurementId": "your_measurementId"
}
firebase = pyrebase.initialize_app(config)
storage = firebase.storage()
path_on_cloud = "<folder>/<file>"
path_local = "<file>"
# Upload
storage.child(path_on_cloud).put(path_local)
# Download
storage.child(path_on_cloud).download("<file_downloaded>")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment