bernhardw
bernhardw

Reputation: 3269

AWS API Gateway: pass through file download as binary

I would like to use API Gateway to pass through binary payloads from a local Express.js server that sends ZIP files in response to GET requests.

However, API Gateway seems to interpret the payload as a string, because I receive the following error when I test the method:

Execution failed due to configuration error: Integration response of reported length 35508489 is larger than allowed maximum of 10485760 bytes.

The response headers of my endpoint are as follows:

Accept-Ranges: bytes
Access-Control-Allow-Origin: *
Cache-Control: public, max-age=0
Connection: keep-alive
Content-Disposition: attachment; filename="rrAIkB6D_v8Htun4hpBx9.zip"
Content-Length: 34173953
Content-Type: application/zip
Date: Fri, 22 Mar 2019 08:37:38 GMT
ETag: W/"2097401-169a0b780ff"
Last-Modified: Thu, 21 Mar 2019 14:46:14 GMT

The download works when the endpoint is accessed directly.

Did I miss something in the configuration?

AWS API Gateway: Overview AWS API Gateway: Method Request AWS API Gateway: Integration Request AWS API Gateway: Method Response AWS API Gateway: Integration Response AWS API Gateway: Method Test AWS API Gateway: Settings

Upvotes: 2

Views: 10244

Answers (2)

Denis Weerasiri
Denis Weerasiri

Reputation: 1160

10 MBs for payload is a hard limit and it applies for all payloads regardless of binary or text. This is mentioned in AWS documentation.

As (a) the file you are trying to transfer is larger than 30MB, (b) you have not configured much complex processing logic in API Gateway configuration, and (c) considering data transfer costs etc, will you be able to check whether your express server can be fronted using an Application Load Balancer? In addition, you may introduce caching (CloudFront), if the response is going to be reused across multiple requests.

Regarding your statement, "API Gateway seems to interpret the payload as a string" can you confirm whether you pass "Accept" header with the value "application/zip" in your HTTP request to the API Gateway?

Upvotes: 3

Vladyslav Usenko
Vladyslav Usenko

Reputation: 2376

First of all, on some pictures I am able to see the ARN of your API Gateway, which means that I can call it and you're gonna pay for it. And if I call it a lot with a script, you're gonna pay even more. In modern cloud world it is called DOW attack (denial of wallet). Be careful! :)

And about the very question, unfortunately API Gateway has a hard limit of 10 MBs for payload. Since it's hard, it seems like it doesn't really fit your use case. :(

Upvotes: 5

Related Questions