API网关将大文件GET/PUT放入S3 [英] API Gateway GET / PUT large files into S3

查看:152
本文介绍了API网关将大文件GET/PUT放入S3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

遵循此AWS文档,我能够在API网关上创建一个新的端点,该端点能够处理S3存储库中的文件.我遇到的问题是文件大小( AWS的有效载荷限制为10MB ).

Following this AWS documentation, I was able to create a new endpoint on my API Gateway that is able to manipulate files on an S3 repository. The problem I'm having is the file size (AWS having a payload limitation of 10MB).

我想知道,是否使用lambda解决方法(此链接将对此有所帮助),是否有可能上传并获取大于10MB的文件(如果需要,甚至可以是二进制文件),因为它使用的是S3服务作为代理-还是不受限制?

I was wondering, without using a lambda work-around (this link would help with that), would it be possible to upload and get files bigger than 10MB (even as binary if needed) seeing as this is using an S3 service as a proxy - or is the limit regardless?

我尝试了PUT ting和GET ting大于10MB的文件,并且每个响应都是典型的"message": "Timeout waiting for endpoint response".

I've tried PUTting and GETting files bigger than 10MB, and each response is a typical "message": "Timeout waiting for endpoint response".

看起来像Lambda是唯一的方法,只是想知道是否有人使用S3作为代理来解决这个问题.

Looks like Lambda is the only way, just wondering if anyone else got around this, using S3 as a proxy.

谢谢

推荐答案

您可以创建Lambda代理函数,该函数将返回带有S3预签名URL的重定向链接.

You can create a Lambda proxy function that will return a redirect link with a S3 pre-signed URL.

生成预签名的S3 URL的示例JavaScript代码:

Example JavaScript code that generating a pre-signed S3 URL:

var s3Params = {
    Bucket: test-bucket,
    Key: file_name,
    ContentType: 'application/octet-stream',
    Expires: 10000
};

s3.getSignedUrl('putObject', s3Params, function(err, data){
   ...
}

然后,您的Lambda函数将重定向响应返回到您的客户端,例如,

Then your Lambda function returns a redirect response to your client, like,

{
    "statusCode": 302,
    "headers": { "Location": "url" }
}

您也许可以从 查看全文

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