简体   繁体   中英

AWS S3 download audio file via API Gateway

I have integrated API gateway with S3 to serve audio files. I want to download it using HTTP endpoint exposed from API Gateway and that's where the audio file is getting corrupted (though serves text file properly). Actual file is 2.9 MB and when I send REST request, res returns file(bin file) having size more than 5 MB. Can anyone help me to fix it?

This is answered here. AWS Api Gateway as a HTTP Proxy is currupting binary uploaded image files

However,with slight changes, this is what worked for me:

  1. In HTTP request, attach the headers as shown.

curl --location --request GET 'https://GATEWAY_URL/pic.jpg' \ --header 'Content-Type: multipart/form-data' \ --header 'Content-Disposition: form-data; name="file"; filename="rahul.jpg"'

  1. In API Gateway settings, add Binary Media Types.

    image/jpeg audio/mpeg multipart/form-data

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM