Uploading greater than 6 MB file to S3 through API Gateway results in Request too long error, Is that expected ?
As I read in AWS documentation, the payload limitation for the API Gateway is 10 MB. My Requirement is to upload files directly to S3 through API Gateway.
When I upload file of greater than 6 MB size, I get "Request too long" error and CloudWatch log shows payload size exceeds 10 MB limit . But while uploading files as binary which is less than 6 MB, it is working as expected. Also, in my case I cannot use Pre-signed URL as an option.
Please suggest any alternative to upload files above 6 MB.
Because binary files are encoded for upload (usually Base64) that increases the size of them during transfer which is probably what you're seeing.
Instead, consider having an API call which triggers a Lambda function to return a pre-signed URL to the client which will allow upload directly to S3. That way you won't have to deal with the limit in API Gateway.
Some example Python code for the Lambda function:
s3 = boto3.client('s3')
presignedURL = s3.generate_presigned_url('put_object',
Params={'Bucket':s3BucketName,
'Key':s3ObjectKey',
'ContentType':objectContentType}
ExpiresIn=linkExpiryTimeInSeconds)
Relevant questions
Uploading greater than 6 MB file to S3 through API Gateway results in Request too long error, Is that expected ?
asked 2 months agoDDOS APIGateway protection
asked 2 months agoApi Gateway Payload size limit increase
asked 5 years agoHow to create Signature V4 authentication header when uploading files as multipart/form-data in REST API of API Gateway?
asked 3 months agoInternal Server Error from API Gateway when sending queries through gateway to Lambda function connected to RDS database
asked 2 months agoLambda response compression to API Gateway and client
asked 4 months agoRecommendations for Amazon's API Gateway 10MB payload limit
Accepted Answerasked 2 years agoAPI Gateway IAM_AUTH role identification
Accepted Answerasked 3 years agoError "413 Request entity too large" - sending file as param to apigateway.
asked 3 years agoPayload size limit on API Gateway
Accepted Answerasked 5 years ago