简体   繁体   中英

Using API Gateway to download already gzipped files from S3

I have an API frontend to a few things, one of those is an S3 bucket containing lots of files.

When I setup a resource that integrates with my S3 bucket, this works perfectly fine for standard text data, but fails for files that are already gzipped.

How do I tell API Gateway to just pass through the gzipped file as a binary stream?

I need to use API Gateway for authentication, so I can't just get around it by using the s3 bucket to serve my files.

I also need gzip encoding turned on for nearly every other endpoint, so turning that off will cause other problems to already working endpoints.

The "other" working content - are there only text files or as well binary content files?

You have to set some parameter when handling binary content with the default (not http-only) API Gaeway. See https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings.html (this is only my assumption about the problem as you still failed to provide any repeatable and validable example, how the API Gateways is providing the content? As Lambda? Code? )

As well there's 10MB limit for API Gateway payload. If you want to return longer content (actually - I'd use it for all content), the API Gateway can return a pre-signed URL for S3 (or web distribution) so the client could download the content of any length from the S3 bucket (directly or through the CloudFront).

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