aws-samples / image-optimization

Simple, performant and cost efficient solution for optimizing images using Amazon CloudFront, Amazon S3 and AWS Lambda
MIT No Attribution
191 stars 114 forks source link

Large (over 6MB) Image Handling #58

Closed amiantos closed 3 hours ago

amiantos commented 3 hours ago

I noticed when serving large files (over 7mb) for the first time, I get an error in the lambda function.

LAMBDA_RUNTIME Failed to post handler success response. Http response code: 413 error

I see discussion online that suggests this may be caused by Lambda having a 6mb payload limit for responses. So I believe what is happening is that when the /original version is created via the lambda task, it is unable to serve the full 6mb+ payload back through CF itself. Subsequent requests, after /original has been created, are served successfully.

I have tested this theory by uploading content to both the storage s3 bucket and creating the /original version in the transformed bucket at the same time. The result was that the image was served successfully on the first request, so my assumption is that this size limit issue is the culprit. However, pre-populating the /original is not really a solution, as there may be transformations that are large as well...

Have I potentially configured something incorrectly on my side, or is this an issue for others?

amiantos commented 3 hours ago

My bad, I had not implemented the maxImageSize Lambda environment variable so the imageTooBig check was not firing for me.

P.S. Thank you all very much for this repo!