Python 从非网页客户端将图像上载到Google应用程序引擎

Python 从非网页客户端将图像上载到Google应用程序引擎,python,google-app-engine,file-upload,blobstore,form-data,Python,Google App Engine,File Upload,Blobstore,Form Data,我有一个googleappengine应用程序Python,它需要允许用户将图像上传到blobstore。客户端将是本地移动应用程序,而不是web应用程序。我有以下代码进行上传: class ImageGetUploadURLHandler(webapp2.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/plain' self.response.ou

我有一个googleappengine应用程序Python,它需要允许用户将图像上传到blobstore。客户端将是本地移动应用程序,而不是web应用程序。我有以下代码进行上传:

class ImageGetUploadURLHandler(webapp2.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write(blobstore.create_upload_url('/imgupload'))

class ImageUploadHandler(blobstore_handlers.BlobstoreUploadHandler):
  def post(self):
    imgInfo = self.get_uploads('img')[0]
    logging.info('Uploading image %s of size %i'.format(imgInfo.filename, imgInfo.size))
    self.redirect('/echo?val=%s' % str(imgInfo.key()))
其中ImageUploadHandler安装在/imgupload上,/echo是一个简单的处理程序,它以text/plain的形式回显在val中传递的任何内容。到目前为止,我只是在使用REST测试工具,因为我还没有启动移动应用程序。我访问了ImageGetUploadHandler,并将结果链接复制到测试应用程序中,在测试应用程序中,我使用了一个包含多部分/表单数据的POST,其中图像文件位于上传URL的正确键下。当我这样做时,我会得到以下错误:

ValueError: Invalid boundary in multipart form: ''

我不知道出了什么问题。非常感谢您的帮助。

您的客户似乎发送了错误的多部分/表单请求。创建一个简单的html表单来测试服务器端,以确保它正常运行:下面是一些关于创建多部分post和boundery的帮助:@PeterKnego:我试过了,我在GAE上遇到了问题。我再试一次。