I working on a mobile application, where user can upload images, am using Django in server side.
我有两种方法得到图像,我想在例外情况下把图像保存到磁盘上。在
imageFile = request.FILES['image']
try:
file_path = imageFile.temporary_file_path()
except AttributeError as e:
logger.debug(virtualFile')
imageStringBuffer = imageFile.read()
virtualFile = StringIO.StringIO(imageStringBuffer)
# want to save the imageStringBuffer to disk
I want to to save the 'virtualFile' (in except case) to the disk , How can I do it?
这将使用请求库来获取图像,打开/创建测试.png把内容写进去。在
参考:here
您不需要
virtualFile
。您已经在imageStringBugger
中拥有图像数据。因此:够了。在
相关问题 更多 >
编程相关推荐