How to serve binary data from AWS API Gateway with proxy integration?

I am building a serverless website with AWS API Gateway (APIG) and Lambda features. I have to use integration with a proxy server because the Lambda function behind should receive HTTP request headers. At the same time, some binary data needs to be maintained. In my case, the favicon.ico file. Other people may want to use dynamically generated PDF or Excel files. APIG has binary support for this purpose. Encode base64 data and configure this type of MIME content so that it can be decoded before it is sent to the client. However, this does not work with proxy integration. Proxy integration simply skips part of the integration response.

I tried redirecting favicon.ico request to the S3 endpoint, but browsers show strange behavior. Because the ico file is from a different and redirected domain, not one domain.

Encoding it with base64 and allowing you to decode the client browser is not an option, since it is not standard and may not work in all browsers.

I suppose I can't do anything until AWS adds a new feature to this. Has anyone looked into this problem? Any idea or suggestion?

+4
source share
1 answer

Answering my own question here. You should go to the AWS forums for AWS questions. There are no mamy AWS users here.

: - DOES WORK , .

3 :

  • MIME APIG ( )
  • "isBase64Encoded" , JSON
  • "Content-type" JSON

, , , .

" " , MIME , APIG base64 "isBase64Encoded". . , base64 true JSON.

, MIME. , JSON MIME .

MIME */*. , - , APIG , . , , base64. , test/html ( ).

0

Source: https://habr.com/ru/post/1672166/


All Articles