Returning binary body and http headers from an AWS lambda through API gateway

前端 未结 3 1925

I have a lambda that needs to return a binary object and some http headers (e.g. content-type) through an api gateway (using lambda integration) OR redirect to another URL.

3条回答
  •  心在旅途
    2021-01-06 21:55

    I tired returning binary data with base64 encoding, but I couldn't manage to return it from Lambda function through API Gateway.

    Therefore, I decided to redirect the URL. I changed the Method Response to 302 and added "Location" Response header. I also deleted response code 200 from Integration Response, selected 302 as response code and mapped integration.response.body.location value with Location header. My Lambda code returned location of redirect URL in this format:

    {"location":"www.google.com/"}
    

    Hope this helps.

提交回复
热议问题