将大于 40MB 的文件上传到 Google App Engine? [英] Upload file bigger than 40MB to Google App Engine?

查看:20
本文介绍了将大于 40MB 的文件上传到 Google App Engine?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个 Google App Engine 网络应用程序来转换"10K~50M 的文件

I am creating a Google App Engine web app to "transform" files of 10K~50M

场景:

  1. 用户在网络浏览器中打开http://fixdeck.appspot.com
  2. 用户点击浏览",选择文件,提交
  3. Servlet 将文件加载为 InputStream
  4. Servlet 转换文件
  5. Servlet 将文件保存为 OutputStream
  6. 用户的浏览器收到转换后的文件并询问将其保存在何处,直接作为对步骤 2 中请求的响应

(目前我没有实现第 4 步,servlet 将文件发回而不进行转换.)

(For now I did not implement step 4, the servlet sends the file back without transforming it.)

问题:它适用于 15MB 的文件,但不适用于 40MB 的文件,说明:错误:请求实体太大.您的客户发出的请求太大."我>

Problem: It works for 15MB files but not for a 40MB file, saying: "Error: Request Entity Too Large. Your client issued a request that was too large."

有什么解决办法吗?

源代码:https://github.com/nicolas-raoul/transdeck
理由:http://code.google.com/p/ankidroid/issues/detail?id=697

推荐答案

GAE 有一个 硬限制 为 32MB.这将限制直接向/从 GAE 应用上传/下载的大小.

GAE has a hard limits of 32MB for HTTP requests and HTTP responses. That will limit the size of uploads/downloads directly to/from a GAE app.

修订后的答案(使用 Blobstore API.)

Revised Answer (Using Blobstore API.)

Google 向 Blobstore API 提供用于处理较大文件在 GAE 中(最多 2GB).概述文档提供了完整的示例代码.您的 Web 表单会将文件上传到 blobstore.然后,blobstore API 将 POST 重写回您的 servlet,您可以在其中进行转换并将转换后的数据保存回 blobstore(作为新的 blob).

Google provides to the Blobstore API for handling larger files in GAE (up to 2GB). The overview documentation provides complete sample code. Your web form will upload the file to blobstore. The blobstore API then rewrites the POST back to your servlet where you can do your transformation and save the transformed data back in to the blobstore (as a new blob).

原始答案(未考虑将 Blobstore 作为选项.)

Original Answer (Didn't Consider Blobstore as an option.)

对于下载,我认为 GAE 唯一的解决方法是将文件在服务器上分成多个部分,然后在下载后重新组装.但是,使用直接的浏览器实现可能无法实现.

For downloading, I think GAE only workaround would be to break the file up in to multiple parts on the server, and then reassemble after downloading. That's probably not doable using a straight browser implementation though.

(作为替代设计,也许您可​​以将转换后的文件从 GAE 发送到外部下载位置(例如 S3),在那里它可以由浏览器在没有 GAE 限制限制的情况下下载.我不相信 GAE 发起的连接具有相同的请求/响应大小限制,但我并不积极.无论如何,您仍然会受到 30 秒最大请求时间的限制.要解决这个问题,您必须查看 GAE 后端实例,并提出某种异步下载策略.)

(As an alternative design, perhaps you could send the transformed file from GAE to an external download location (such as S3) where it could be downloaded by the browser without the GAE limit restrictions. I don't believe GAE initiated connections have same request/response size limitations, but I'm not positive. Regardless, you would still be restricted by the 30 second maximum request time. To get around that, you'd have to look in to GAE Backend instances and come up with some sort of asynchronous download strategy.)

为了上传更大的文件,我已经了解了使用 HTML5 文件 API 将文件分成多个块进行上传,然后在服务器上重建的可能性.示例:http://www.html5rocks.com/en/教程/文件/dndfiles/#toc-slicing-files.但是,我不知道真正是由于不断变化的规范和浏览器功能而提供的解决方案有多实用.

For uploading larger files, I've read about the possibility of using HTML5 File APIs to slice the file in to multiple chunks for uploading, and then reconstructing on the server. Example: http://www.html5rocks.com/en/tutorials/file/dndfiles/#toc-slicing-files . However, I don't how practical a solution that really is due to changing specifications and browser capabilities.

这篇关于将大于 40MB 的文件上传到 Google App Engine?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆