【问题标题】:Uploading images to s3 with meta = image/jpeg - python/boto3使用 meta = image/jpeg - python/boto3 将图像上传到 s3
【发布时间】:2018-09-12 04:25:36
【问题描述】:

如何将我使用 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

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

提前谢谢你!

【问题讨论】:

    标签: python amazon-web-services amazon-s3 boto3


    【解决方案1】:

    将其添加到ExtraArgs 参数中:

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

    【讨论】:

      猜你喜欢
      • 2021-07-22
      • 1970-01-01
      • 1970-01-01
      • 2019-04-29
      • 2023-03-30
      • 2017-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多