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?
More detail here: https://stackoverflow.com/questions/67377365/aws-lambda-doesnt-return-binary-content
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.
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.
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 : )
Oh, and I also have contentHandling: apigateway.ContentHandling.CONVERT_TO_BINARY