Skip to content

Instantly share code, notes, and snippets.

@raghavmri
Created June 17, 2020 10:13
Show Gist options
  • Save raghavmri/9beb5f66c7505725cb902a670c70e9ee to your computer and use it in GitHub Desktop.
Save raghavmri/9beb5f66c7505725cb902a670c70e9ee to your computer and use it in GitHub Desktop.
import pyrebase
config = {
"apiKey": "Your API Key",
"authDomain": "YourprojectId.firebaseapp.com",
"databaseURL": "https://YourdatabaseName.firebaseio.com",
"storageBucket": "YourprojectId.appspot.com",
"serviceAccount": "path/toyour/serviceAccountCredentials.json"
}
# initialisatiing pyrebase
firebase = pyrebase.initialize_app(config)
storage = firebase.storage()
# uploading as a ADMIN
storage.child("images/example.jpg").put("example2.jpg")
# uploading as a user
storage.child("images/example.jpg").put("example2.jpg", user['idToken'])
# To download a file
storage.child("images/example.jpg").download("downloaded.jpg")
# To get a specific file's url
storage.child("images/example.jpg").get_url() # https://firebasestorage.googleapis.com/v0/b/storage-url.appspot.com/o/images%2Fexample.jpg?alt=media
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment