如何通过应用引擎将图像上传到云存储? [英] how to upload image to the cloud storage via app engine?
本文介绍了如何通过应用引擎将图像上传到云存储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I am using python with google app engine. I would like to get image from the browser and upload it to cloud storage.
the form:
<form action="http://myappId.appspot.com/test/uploadImage" method="post">
<input type="file" name="file" value='file'><br>
<input type="submit" value="Submit">
</form>
my server side:
class uploadImageTOCloudStorage(webapp2.RequestHandler):
def post(self):
image = self.request.get("file")
gcs_file=gcs.open(GCS_BUCKET_NAME+'testImage.png', 'w')
gcs_file.write(image.encod('utf-8'))
gcs_file.close()
self.response.write("succeed !")
the file saved in the cloud storage, but the problem that I couldn't download it, I got this error:
The file could not be opened, it may be damaged or user a file format that preview doesn't recognize !
what should I do ?
I don't want to use blobstore, because create_upload_url
will be active just for ten minutes.
解决方案
Could it be because you do not have a proper enctype="multipart/form-data"
for your form?
这篇关于如何通过应用引擎将图像上传到云存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文