[英]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. 我需要使用网络应用程序将PDF文件上传到s3存储桶。 I am following serverless architecture with AWS lambda.
我正在使用AWS Lambda跟踪无服务器架构。 Is this possible with AWS API Gateway and lambda?
AWS API Gateway和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.
我建议使用API Gateway作为S3的代理,并在上传时跳过Lambda函数。 Then you can use S3 events to run any necessary Lambda functions for processing the object after upload.
然后,您可以使用S3事件来运行任何必要的Lambda函数,以在上传后处理该对象。
The most convenient/efficient way to upload to S3 is by using presigned urls . 上传到S3的最方便/最有效的方法是使用预签名的url 。 By doing so, you delegate on S3 proven API to do the heavy lifting for you.
这样,您可以委托经过S3验证的API来为您完成繁重的工作。
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. 您的应用程序将仅使用lambda函数来获取预签名的url,然后直接将上传文件上传到S3,当然,上传文件后,您当然可以使用第二个lambda文件进行处理。
You can see a write-up of a similar solution (without API Gateway) at Stratosparks's blog 您可以在Stratosparks的博客上看到类似解决方案的内容(没有API网关)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.