Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase maximum POST size for Amazon API Gateway

I intend to use AWS API Gateway & Lambda to perform a file upload to S3, via POST from a HTML form. However, the API Gateway endpoint will fail if the file is big enough, with message [HTTP content length exceeded 10485760 bytes.].

Do you happen to know any way to increase this limit?

It is the same irrespective if the API method hides a Lambda function or is simply a mock method.

like image 944
Senin Avatar asked Nov 17 '15 16:11

Senin


2 Answers

There is currently no way to increase this limit.

Additionally, API Gateway is not currently optimized to support binary transfer to S3. This is a request we have heard from other customers and we may add support for this in the future.

Update 2017-02-19: While there is still no way to increase payload size limits, API Gateway does now support binary data.

like image 111
Bob Kinney Avatar answered Nov 20 '22 07:11

Bob Kinney


You can use the multi-part upload functions available as part of the S3 API.

https://docs.aws.amazon.com/AmazonS3/latest/dev/uploadobjusingmpu.html

You would have to add three endpoints to start the process, upload a chunk, and complete the process. Also consider adding an abort routine.

Client side, you would need to chunk the file into segments, and then upload them asynchronously.

This gets each post under API Gateway's 10MB limit. Obviously, you can't do that with a standard html form and would need some javascript handling to chunk the file and handle the asynchronous request.

Alternatively, you could bypass the gateway and post directly to the S3 Rest API. However, you lose the benefits of the gateway and introduce some security risks.

https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html

like image 1
Jesse Bethke Avatar answered Nov 20 '22 08:11

Jesse Bethke