Fork me on GitHub
#aws
<
2021-05-03
>
cfleming10:05:55

Has anyone successfully used a lambda proxy integration to return binary data? I cannot for the life of me get AWS to convert the base64 encoded response to binary. I’m returning content-type: application/zip (checked with curl), I have binaryMediaTypes: ["application/zip"] set on my REST API with CDK and I’ve checked in the console that it’s there, and I’m passing curl -i -H "Accept: application/zip" <url>, and I’m still getting base64 encoded text back. Any further ideas?

1
cfleming10:05:51

Oh, and I also have contentHandling: apigateway.ContentHandling.CONVERT_TO_BINARY

dabrazhe11:05:25

The gut feeling is there’s something off with the API Gateway settings ( i am not familiar with it enough to be sure). You could try invoking the Lambda function directly, via its url, and reproduce the issue.

cfleming03:05:23

Yes, it must be a problem with the API gateway, since the lambda is behaving correctly. When using the lambda proxy integration, the lambda has to return base64 (which it is) but for some reason I’m missing the magic incantation to make API gateway convert that result to binary data.

dabrazhe12:05:21

If you have the option of AWS tech support you can ask them the question, or ask a friend who has access to the AWS support : )