Search code examples
amazon-web-servicesaws-api-gatewayapi-gateway

Api gateway integration with s3


I'm trying to build a rest api on AWS, using API Gateway. My wish is that using the API Gateway integration with S3, I can upload files to the bucket in users' directories.

In the first steps, I managed to create the API that uploads to the s3 bucket, with the cognito authorizer. But I can't get it to only upload prefixes with the user's name, for example.

Is there any way this can be done?

Upload a file into a user prefix exclusive bucket.


Solution

  • It is not a good idea to upload files to S3 using Amazon API Gateway directly. Amazon API Gateway has a payload size limit of 10 MB. A better approach would be to generate an S3 PreSigned URL using a Lambda function and then send that URL to the frontend to upload the file. When creating the PreSigned URL, you are free to name S3 object key what