我需要将图像上传到Firebase Storage,我想用postrongave信号或save方法来完成。但既然Firebase是纯JS,我怎么能在models.py中做到呢?以下是如何使用FirebaseWeb:上传的参考资料
https://firebase.google.com/docs/storage/web/upload-files
您将想要使用谷歌云存储:
# Import
from google.cloud 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')