Created
June 17, 2020 10:13
-
-
Save raghavmri/9beb5f66c7505725cb902a670c70e9ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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