如何从GAE上传文件到S3(一个恐怖故事)

发布于 2024-12-20 23:09:53 字数 988 浏览 0 评论 0原文

我正在尝试从 GAE 将文件上传到亚马逊 S3。

我尝试了官方的亚马逊sdk(jetS3t,构建在较低级别的sdk),只是为了找出即使你可以让它工作通过在本地 JVM 上设置权限在本地进行部署后,由于 GAE 加密相关的原因,它不再受支持。

然后出于绝望,我发现一些好人 分叉了官方的低级亚马逊sdk,以便它可以与 GAE 一起使用。这种工作原理(尽管我可以看到到处抛出一些 stage NullPointer 异常)并且文件被上传......但是如果文件大小超过 5MB,我会从 API 中收到错误:

com.google.apphosting.api.ApiProxy$RequestTooLargeException: The request to API call urlfetch.Fetch() was too large

我不完全理解这一点是因为当前的 GAE 对文件大小上传的限制似乎是 32MB,对请求/响应的限制似乎是 1MB,而我的问题仅在文件大小约为 5MB 或更大时才会出现。

我认为我唯一剩下的选择是 jclouds,但我无法找到使用 BlobStore 将文件上传到 S3 的示例图书馆。

有人有分享使用 jClouds 上传 S3 文件的经验/示例吗?我是否可能会遇到相同的 urlfetch.Fetch() 太大 错误?

感谢任何帮助。

I am trying to upload a file to amazon S3 from GAE.

I tried the official amazon sdk (jetS3t, built on top of the lower-level sdk), just to find out that even if you can get it to work locally by setting permissions on the local JVM it is not supported for GAE crypto-related reasons once you deploy it.

Then out of desperation I found that some good soul forked the official low-level amazon sdk so that it would work with GAE. This kind of works (even though I can see some strage NullPointer exceptions being thrown here and there) and the file gets uploaded ... but if the file size exceeds 5MB I am getting a error from within the API:

com.google.apphosting.api.ApiProxy$RequestTooLargeException: The request to API call urlfetch.Fetch() was too large

I don't fully understand this as the current GAE limitations seem to be 32MB on file size upload and 1MB on request/response while my problem is occurring only when the file is around 5MB or bigger.

I think my only alternative left is jclouds, but I am having trouble finding examples of uploading files to S3 using the BlobStore library.

Does anyone have experience/examples to share of S3 file upload with jClouds? And am I likely to incur in the same urlfetch.Fetch() was too large error?

Any help appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浮云落日 2024-12-27 23:09:53

URLFetch 请求的大小限制为 5MB,如此处所述。唯一可行的解​​决方案是将大的有效负载分解成更小的块。幸运的是,S3 提供了分段上传 API

URLFetch requests are limited to 5MB, as documented here. The only solutions that will work are those that involve breaking up a large payload into smaller chunks. Fortunately, S3 provides a multipart upload API.

够运 2024-12-27 23:09:53

1.5.0 版本说明中,我阅读了为了响应大众的需求,HTTP 请求和响应大小已增加到 32 MB。因此,请求和响应、URL 获取均未提及。

事实上,查看URL Fetch 文档,它说最大 5 Mb。

On the release notes for 1.5.0, I read In response to popular demand, the HTTP request and response sizes have been increased to 32 MB. So, request and response, URL fetch is not mentioned.

Indeed, looking at URL Fetch documentation, it says it's max 5 Mb.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文