Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

API Gateway GET / PUT large files into S3

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).

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?

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

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

Thanks

like image 475
Hexie Avatar asked Mar 23 '17 04:03

Hexie


People also ask

Can API gateway write to S3?

To upload a binary file (image) to an S3 bucket using API Gateway, you must activate binary support for your API Gateway REST API. To allow your API to access your S3 bucket, you must also create an AWS Identity and Access Management (IAM) role.

How will you upload a file greater than 100 megabytes in Amazon S3?

Instead of using the Amazon S3 console, try uploading the file using the AWS Command Line Interface (AWS CLI) or an AWS SDK. Note: If you use the Amazon S3 console, the maximum file size for uploads is 160 GB. To upload a file that is larger than 160 GB, use the AWS CLI, AWS SDK, or Amazon S3 REST API.

Can we upload 6tb file to S3?

The size of an object in S3 can be from a minimum of 0 bytes to a maximum of 5 terabytes, so, if you are looking to upload an object larger than 5 gigabytes, you need to use either multipart upload or split the file into logical chunks of up to 5GB and upload them manually as regular uploads.


1 Answers

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

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){
   ...
}

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

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

You might be able to find more information you need from this documentation.

like image 195
Ka Hou Ieong Avatar answered Nov 15 '22 21:11

Ka Hou Ieong