2

I have been trying to read the AWS Lambda@Edge documentation, but I still cannot figure out if the following option is possible.

Assume I have an object (image.jpg, with size 32922 bytes) and I have setup AWS as static website. So I can retrieve:

$ GET http://example.com/image.jpg

I would like to be able to also expose:

$ GET http://example.com/image

Where the response body would be a multipart/related file (for example). Something like this :

--myboundary
Content-Type: image/jpeg;
Content-Length: 32922
MIME-Version: 1.0

<actual binary jpeg data from 'image.jpg'>
--myboundary

Is this something supported out of the box in the AWS Lambda@Edge API ? or should I use another solution to create such response ? In particular it seems that the response only deal with text or base64 (I would need binary in my case).

malat
  • 12,152
  • 13
  • 89
  • 158
  • Although not clear on that page, I think the base64 encoding _is_ for sending binary data. The whole response is going to be passed between Lambda and CloudFront in a text format like JSON, so you have to encode that data somehow _internally_; CloudFront will immediately decode it again and serve the actual binary data. Not very efficient, but simpler to implement than an actual binary protocol. – IMSoP Mar 02 '21 at 13:57

1 Answers1

0

I finally was able to find complete documentation. I eventually stumble upon:

which refers to:

The above documentation specify the steps to handle binary data. Pay attention that you need to base64 encode the response from lambda to pass it to API Gateway.

malat
  • 12,152
  • 13
  • 89
  • 158