[英]Error/Wrong Content-Type while saving image using pillow package in python on AWS Lambda
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 '我正在尝试使用枕头 package 使用 python 生成立体图像。我面临的问题是“内容类型自动转换为二进制/八位字节流,但我的原始图像内容类型是图像/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)
Finally found the solution, problem is while uploading the file to s3 you need to specify the content-type explictly.终于找到了解决方案,问题是将文件上传到 s3 时需要明确指定内容类型。
s3_client.upload_file(upload_path, '{}'.format(bucket),
f'{filename}',ExtraArgs={'ContentType': '{}'.format(mimeType),'Metadata':{}})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.