Reputation: 363
I'm trying to generate dimensional images using a pillow package using python. The problem I'm facing is 'Content-Type gets converting automatically to binary/octet-stream but my original image Content-Type is image/jpeg'
Here is code which I'm using to generate thumbnails
def resize_image(image_path, resized_path, thumbnail_size):
with Image.open(image_path) as image:
image.thumbnail((thumbnail_size["x"], thumbnail_size["y"]))
image.save(resized_path,"JPEG",progressive=True)
Upvotes: 0
Views: 286
Reputation: 363
Finally found the solution, problem is while uploading the file to s3 you need to specify the content-type explictly.
s3_client.upload_file(upload_path, '{}'.format(bucket),
f'{filename}',ExtraArgs={'ContentType': '{}'.format(mimeType),'Metadata':{}})
Upvotes: 1