问题
I am having trouble uploading images to Firebase using Python. it would be great help if someone can provide a snippet.
回答1:
Take a look at gcloud-python, or our docs on using GCS APIs with Firebase Storage. From those docs:
# Import gcloud
from google.cloud import storage
# Enable Storage
client = storage.Client()
# Reference an existing bucket.
bucket = client.get_bucket('projectid.appspot.com')
# Upload a local file to a new file to be created in your bucket.
zebraBlob = bucket.get_blob('zebra.jpg')
zebraBlob.upload_from_filename(filename='/photos/zoo/zebra.jpg')
# Download a file from your bucket.
giraffeBlob = bucket.get_blob('giraffe.jpg')
giraffeBlob.download_as_string()
来源:https://stackoverflow.com/questions/40085677/how-to-upload-images-to-firebase-from-raspberry-pi