AWS: Large File Upload - API Gateway & Lambda - Be

2020-04-20 08:53发布

问题:

I need a user to be able to provide a 15 MB XML file to an AWS Lambda function for it to perform an action, and return another XML file back to the user. This is the only thing this "application" is going to do. The data in the XML file is semi-sensitive and shouldn't be kept anywhere after the file is returned.

What are the best practices for handling this? The API Gateway appears to have a payload size limit of 10mb, so I can't just upload it.

I've seen some references to having the file uploaded directly to S3, and then having that action trigger the Lambda function automatically. However, in this scenario, how does the user get the output file from the Lambda function returned? I really don't want it sitting around for a long time.

I'm hoping to keep this application as simple as possible.

回答1:

If you're considering using S3 for this purpose and making the whole process asynchronous your Lambda function can write the output to S3 as well, then generate presigned url to the file and send it back to the user. You can have lifecycle policy on S3 bucket to remove the files when they're not needed anymore or have another Lambda function deleting them based on the notification.