Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I bypass the 10MB limit of AWS API gateway and POST large files to AWS lambda?

what I want

An API which takes file and some parameters using POST and gives back a JSON response.

curl -X POST www.endpoint.com \
   -F file=@/myfile.txt \
   -F foo=bar # other params

I have this working with Lambda + API gateway using binary data but 10MB limit is the issue.

I have considered a POST API which uploads file to S3. The event generated is then read by Lambda. But for this I have few questions-

  1. Where will my other parameters go?
  2. How will Lambda return back the response?
like image 760
secretshardul Avatar asked Nov 22 '19 11:11

secretshardul


People also ask

How do I get around Lambda payload limit?

However, we can get around this limit by using an AWS S3 pre-signed url for uploads. This allows our AWS Lambda function to instead generate a pre-signed url and return it to our client, then our client can use that temporary pre-signed url to upload directly to our AWS S3 bucket.

What is the max size of Lambda package in AWS?

128 MB to 10,240 MB, in 1-MB increments.


1 Answers

Your use case simply isn't possible with one API call if you want to stick with a serverless solution.

A possible serverless solution would be a 3 step process for the client.

Step 1

Call api1 to get a signed url for S3. This would point to a Lambda that creates a UUID and uses that UUID to construct a signed URL for S3 (i.e. uses the UUID as the filename of the file being received). The response would be the URL and the UUID.

Step 2

PUT file to s3 using the signed URL.

Step 3

Call api2 and pass the UUID and what ever other parameters are required. This api also points to a Lambda which now knows where the file is (thanks to the UUID) and has whatever other parameters are required to process the file and give a response.

like image 67
K Mo Avatar answered Sep 20 '22 10:09

K Mo