AWS API Gateway and Lambda to return image

后端 未结 5 2188
情书的邮戳
情书的邮戳 2021-02-19 06:02

Say I have this HTML:


What I would like to do is have example.com/pic map to an AWS API Gateway end

5条回答
  •  我在风中等你
    2021-02-19 06:44

    Luckily, now AWS API Gateway supports binary data, though you also need to update your resource method through the CLI as it is not yet implemented in the Console. This is what you need to do:

    1. In the Method Response of your method
      Set Content-Type as image/jpeg in HTTP 200 Status Response Header
    2. In the Integration Response of your method
      Set Content-Type as 'image/jpeg' in Header Mappings. Mind the quotes!
    3. With the AWS CLI, set contentHandling attribute to CONVERT_TO_BINARYon your Integration Response

    Check to entire process in this great step-by step guide: https://stackoverflow.com/a/41434295/720665

提交回复
热议问题