Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.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
阿拉莫菲尔是如何做到的;上传“;从Swift到后端的图像?_Swift_Django_Google Cloud Storage_Alamofire_Alamofireimage - Fatal编程技术网

阿拉莫菲尔是如何做到的;上传“;从Swift到后端的图像?

阿拉莫菲尔是如何做到的;上传“;从Swift到后端的图像?,swift,django,google-cloud-storage,alamofire,alamofireimage,Swift,Django,Google Cloud Storage,Alamofire,Alamofireimage,我正在尝试将图像从Swift上传到我的Django后端,这样我就可以将它们存储在Google云存储中,并在Django的数据库模型中作为“外键”访问它们。似乎有一个内置的库来连接Django模型和Google存储 参考资料。 在将图像发送到后端之前,图像将转换为UIImageJPEG表示。Alamofire如何通过“multipartFormData”发送图像?它只是以字符串形式发送原始UIImageJPEG表示吗 我这样问是因为我需要以某种方式转换我在后端收到的图像数据,并将其存储在Djang

我正在尝试将图像从Swift上传到我的Django后端,这样我就可以将它们存储在Google云存储中,并在Django的数据库模型中作为“外键”访问它们。似乎有一个内置的库来连接Django模型和Google存储

参考资料。 在将图像发送到后端之前,图像将转换为UIImageJPEG表示。Alamofire如何通过“multipartFormData”发送图像?它只是以字符串形式发送原始UIImageJPEG表示吗

我这样问是因为我需要以某种方式转换我在后端收到的图像数据,并将其存储在Django模型中,同时将其上传到Google存储

从文件中:

>>> class Resume(models.Model):
...     pdf = models.FileField(upload_to='pdfs')
...     photos = models.ImageField(upload_to='photos')
要将本地文件存储到云存储并同时存储在模型字段中,请执行以下操作:

>>> obj1.pdf.save('django_test.txt', ContentFile('content'))
>>> obj1.pdf
<FieldFile: tests/django_test.txt>
obj1.pdf.save('django_test.txt',ContentFile('content')) >>>obj1.pdf 对于阿拉莫菲尔发送的图像,是否需要这样的处理

>>> obj1.photos.save(<Insert whatever was sent from Alamofire>)
>>obj1.photos.save()
如果是,您如何访问Alamofire发送的数据

>>> obj1.photos.save(<Insert whatever was sent from Alamofire>)