How to change content type of Amazon S3 Objects

后端 未结 3 747
情书的邮戳
情书的邮戳 2020-12-06 05:06

The objects in my Amazon S3 bucket are all of the content type application/octet-stream. Some of these objects are PDFs, sometimes images like JPG,

3条回答
  •  鱼传尺愫
    2020-12-06 05:55

    You can use AWS sdk (php or other) I'll show how it works using CLI. To change content type on S3 given object, you need to copy this object and update the metadata information using the REPLACE tag so it copies to itself, you can achieve that using http://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html

    aws s3api copy-object --bucket  \
        --content-type "images/jpeg" \
        --copy-source /path/to/images.jpeg \
        --key path/to/images.jpeg \
        --metadata-directive "REPLACE"
    

提交回复
热议问题