gpt4 book ai didi

python - 使用 meta = image/jpeg - python/boto3 将图像上传到 s3

转载 作者:行者123 更新时间:2023-11-28 22:19:36 24 4
gpt4 key购买 nike

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

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

s3.upload_fileobj(bytes_io_file, bucket_name, filename)

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

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

提前致谢!

最佳答案

ExtraArgs 参数中添加:

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

关于python - 使用 meta = image/jpeg - python/boto3 将图像上传到 s3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49619986/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com