0

I have an api. I want to serve content that is 180 mb. I can't use api gateway as its limit is 10 mb. Therefore I am placing the file in s3.

Now for that s3 url I still want to have api keys. That means I will need to go through the api gateway. Is this possible somehow to redirect to s3 url only from api gateway after key is verified without exposing the s3 url publicly?

This is not the same question as discussed here. I followed that question and am able to upload the bigger file to s3 bucket.

Now more clearly the question here is how to access this s3 url for downloading the file using API gateway with an API key? Can we do that?

E_net4
  • 27,810
  • 13
  • 101
  • 139
muasif80
  • 5,586
  • 4
  • 32
  • 45
  • Does this answer your question? [Request payload limit with AWS API Gateway](https://stackoverflow.com/questions/46358922/request-payload-limit-with-aws-api-gateway) – esqew Mar 30 '21 at 12:31
  • No. Its about uploading using apis etc. I am just asking about the configuration of the api gateway to point to s3 resource. Now if the s3 resource is bigger than 10 mb it will still not work due to api gateway limit right? – muasif80 Mar 30 '21 at 12:33
  • 1
    The first answer in the linked question mentions and links to pertinent information about how to work around this limit, specifically for S3. – esqew Mar 30 '21 at 12:44
  • I have followed that link and I am able to save to the s3 a bigger file like 180 mb from my code running on ec2 machine in spring boot app. Now how to access that file through api gateway does that question answer that? If yes i will go back and look into it. otherwise please understand this is a different question here. Thanks. – muasif80 Mar 30 '21 at 12:52
  • But let me be very clear that this is a different question not the one answered somewhere else. Let me put more details to the question too. – muasif80 Mar 30 '21 at 12:53
  • Thanks for cleaning the question "E_net4 the curator". – muasif80 Mar 30 '21 at 18:30

1 Answers1

2

Let your API return a pre-signed URL. https://docs.aws.amazon.com/AmazonS3/latest/userguide/ShareObjectPreSignedURL.html You can set the time for how long the link will be valid. The client then downloads from the download URL, does it work for you?

petrch
  • 1,807
  • 15
  • 19
  • Thanks. This should work. But its like getting the url instead of the resource itself. Then sending another request to that Pre-Signed URL. Can we actually redirect from API gateway to this Pre-Signed URL – muasif80 Mar 30 '21 at 14:32
  • 2
    Well, the api can return an HTTP Redirect if it is designed that way. Another way I am thinking about is to use CloudFront where you can create some lambda filters and possibly you can change headers/cookies, but I did not work with it, I worked on an unrelated issue, so I know it should be possible, but did not try it. – petrch Mar 30 '21 at 14:36
  • I am sending the pre-signed URL for now from my spring boot endpoint from the app hosted there. – muasif80 Mar 30 '21 at 18:30