Reputation: 551
I have a chalice application
that has a defined lambda_handler
that will be triggered using s3 event notifications. Every time an image is created in my s3 bucket, the lambda_handler
function will be invoked to create thumbnails. But when you upload images to s3 using presigned_urls
, the uploaded file does not have a file extension.
The files on s3 look like this:
Now when using pillow, an error is thrown unknown extension file
.
How should I go about this?
Upvotes: 1
Views: 241
Reputation: 33
Do you have access to the function that is in charge of performing the image upload?
If you're using a pre-signed post to perform the image upload, you should also specify the file extension within the object_name parameter.
response = s3_client.generate_presigned_post(BUCKET_NAME,
"5eafba9fa31dd3bcc190a52.jpg",
Fields=fields,
Conditions=conditions,
ExpiresIn=expiration)
This will cause images to be uploaded with their proper extensions, therefore allowing any subsequent invocation to have the proper file extension.
If you only have access to your chalice application, if there's any guarantee that the file extension will always be of a certain type, you can append the extension prior to using Pillow.
Upvotes: 1