如何从Raspberry Pi上传图像到Firebase?

时间:2016-10-17 11:50:52

标签: python-2.7 firebase raspberry-pi firebase-storage

我无法使用Python将图片上传到Firebase。如果有人可以提供一个片段,那将会很有帮助。

1 个答案:

答案 0 :(得分:1)

使用Firebase存储查看gcloud-pythonour docs on using GCS APIs。从那些文档:

# 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()