0
我需要將圖片上傳到Firebase存儲,我正在考慮使用post_save信號或保存方法。但是由於Firebase是純JS,我怎樣才能在models.py中做到這一點?下面是如何與火力地堡網絡上傳參考:從FileField的django模型將圖片上傳到Firebase存儲
https://firebase.google.com/docs/storage/web/upload-files
我需要將圖片上傳到Firebase存儲,我正在考慮使用post_save信號或保存方法。但是由於Firebase是純JS,我怎樣才能在models.py中做到這一點?下面是如何與火力地堡網絡上傳參考:從FileField的django模型將圖片上傳到Firebase存儲
https://firebase.google.com/docs/storage/web/upload-files
你會想用gcloud-python此:
# Import
from gcloud import storage
# Initialize
client = storage.Client()
bucket = client.get_bucket('bucket-id-here')
# Download
blob = bucket.get_blob('remote/path/to/file.txt')
print blob.download_as_string()
# Upload
blob2 = bucket.blob('remote/path/storage.txt')
blob2.upload_from_filename(filename='/local/path.txt')
見小李的答案在這裏最後一個註釋是:http:/ /stackoverflow.com/questions/38521949/is-there-any-supported-way-for-a-firebase-service-accounts-to-write-to-your-clou/38532457#38532457 –