Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将图像从文件字段中的django模型上载到Firebase存储_Django_Firebase_Firebase Storage - Fatal编程技术网

将图像从文件字段中的django模型上载到Firebase存储

将图像从文件字段中的django模型上载到Firebase存储,django,firebase,firebase-storage,Django,Firebase,Firebase Storage,我需要上传一个图像到Firebase存储器,我想用post_保存信号或保存方法来完成。但是由于Firebase是纯JS,我如何在models.py中实现它呢?以下是如何使用Firebase Web上载的参考: 您将要为此使用: # Import from google.cloud import storage # Initialize client = storage.Client() bucket = client.get_bucket('bucket-id-here') # Downlo

我需要上传一个图像到Firebase存储器,我想用post_保存信号或保存方法来完成。但是由于Firebase是纯JS,我如何在models.py中实现它呢?以下是如何使用Firebase Web上载的参考:


您将要为此使用:

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

请参见Mike回答中的最后一条评论: