使用 meta = image/jpeg

编程入门 行业动态 更新时间:2024-10-25 05:12:50
本文介绍了使用 meta = image/jpeg - python/boto3 将图像上传到 s3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

如何将使用 boto3 上传到 AWS S3 的图像的 ContentType 设置为 content-type:image/jpeg?

How do I go about setting ContentType on images that I upload to AWS S3 using boto3 to content-type:image/jpeg?

目前,我使用以下命令使用 buto3/python 2.7 将图像上传到 S3:

Currently, I upload images to S3 using buto3/python 2.7 using the following command:

s3.upload_fileobj(bytes_io_file, bucket_name, filename)

但是,要将上传对象的类型设置为 ContentType='image/jpeg',我必须通过 Web 界面手动选择 S3 上的所有文件夹",并将元数据设置为 Content-type : Image/jpeg

However, to set the uploaded object's type to ContentType= 'image/jpeg', I have to manually select all 'folders' on S3 through the web interface, and set metadata to Content-type : Image/jpeg

有没有办法在我上面的上传请求中设置这个标志?

Is there a way to set this flag in the upload request i have above?

先谢谢你!

推荐答案

将其添加到 ExtraArgs 参数中:

Add it in the ExtraArgs argument:

s3.upload_fileobj(bytes_io_file, bucket_name, filename, ExtraArgs={ "ContentType": "image/jpeg"})

这篇关于使用 meta = image/jpeg - python/boto3 将图像上传到 s3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-23 04:43:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1035515.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:meta   image   jpeg

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!