如何将文件上传到blobstore

时间:2013-11-24 07:52:30

标签: python google-app-engine blobstore

当我提交上传表格时,会显示以下错误。 我该如何解决?

  

404 Not Found   无法找到资源。

python代码

class DashboardHandler(webapp2.RequestHandler):
    def get(self):
        upload_url = blobstore.create_upload_url('/upload')

class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
    def post(self):
        upload_files = self.get_uploads('file')
        blob_info = upload_files[0]
        self.redirect('/serve/%s' % blob_info.key())

app = webapp2.WSGIApplication([
    ('/(mysitename)/upload', UploadHandler),
debug=True)

HTML(模板)

<form action={{upload_url}} method="post" enctype="multipart/form-data">
  <input type="file">
  <input type="submit" name="UPLOAD">
</form>

我正在使用原始域名,因此错误网址如下所示。

 HTTP:// WWW(MySiteName).ME / _ah /上传/ AMmfu6b74Szd5r2OSm0DYxF4sZ4tQNW7JjIDqaNwagaKRvy4eptgqc-WVRKIBd6w_SBFnpN7tjVaNujW_H7U5ftmmYT34fTnD_TjsyawkE1VTj6OrYCpsxQwO7RRnLj6yOfWLOdJbg6A / ALBNUaYAAAAAUpGu2FSrupya8eMAP-afGYgToYnHa9aD /

1 个答案:

答案 0 :(得分:0)

您没有提供很多细节,因此难以诊断。您使用的是blobstore_handlers.BlobstoreUploadHandler而不是常规RequestHandler吗?如果是,请显示该处理程序以及WSGIApplication设置的相关部分。