: Create a role that grants s3:GetObject permissions for your specific bucket and allow ://amazonaws.com to assume it.
: In the API Gateway console, navigate to Settings and add */* to Binary Media Types . This ensures images, PDFs, and other binaries aren't corrupted during transfer. Configure the Method : Create a GET method. Set Integration Type to AWS Service . Select S3 as the service and GetObject as the action. download file from s3 using api gateway
Downloading files from through API Gateway is a common pattern for exposing private storage as a secure REST API. You can achieve this using two primary methods: a direct AWS Service Proxy (no code) or an AWS Lambda Integration (custom logic). Comparison of Methods Direct S3 Proxy Lambda Integration Pre-signed URLs Effort Low (Configuration only) Medium (Requires code) Low/Medium Max File Size 10 MB (Hard limit) 6 MB (Sync limit) Unlimited (Up to 5GB) Use Case Static assets, simple proxying Dynamic naming, transformations Large files, high throughput Option 1: Direct API Gateway to S3 Proxy (No-Code) : Create a role that grants s3:GetObject permissions
In the , map the URL parameters to the S3 path using an execution role. Configure the Method : Create a GET method
Use this if you need to perform authentication checks or log download history before serving the file.
Copyright @2023 ZAMBIA CIRT