简体   繁体   中英

Is it possible to upload a PDF file through AWS API Gateway and a lambda function to a S3 bucket?

I need to upload a PDF file using a web application to s3 bucket. I am following serverless architecture with AWS lambda. Is this possible with AWS API Gateway and lambda? I am using node by the way.

Yes, this is possible and there are many different solutions. I would suggest using API Gateway as a proxy to S3 and skipping the Lambda function on upload. Then you can use S3 events to run any necessary Lambda functions for processing the object after upload.

The most convenient/efficient way to upload to S3 is by using presigned urls . By doing so, you delegate on S3 proven API to do the heavy lifting for you.

Your application would use a lambda function just to get the presigned url, then the upload would be directly to S3, and of course you can process the file with a second lambda once it uploads.

You can see a write-up of a similar solution (without API Gateway) at Stratosparks's blog

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