【问题标题】:How to apply content type to Amazon S3 objects如何将内容类型应用于 Amazon S3 对象
【发布时间】:2016-12-19 14:32:10
【问题描述】:

使用CLI(不是s3cmd)管理Amazon S3,如何选择扩展名为.pdf的所有对象并应用内容类型application/pdf

这是我目前想出的:

aws s3 sync s3://${BUCKET_NAME} s3://${BUCKET_NAME}
--dryrun
--exclude '*'
--include '*.pdf'
--no-guess-mime-type
--content-type application/pdf

使用--debug 参数我发现了这个错误:

An error occurred (InvalidRequest) when calling the CopyObject operation:
This copy request is illegal because it is trying to copy an object to itself
without changing the object's metadata, storage class,
website redirect location or encryption attributes.

【问题讨论】:

  • 你能在没有选项的情况下尝试你的命令吗?然后一一添加选项,看看什么时候失败?
  • @Sylwit 我使用了 --debug 参数,发现错误并更新问题。
  • stackoverflow.com/a/58041788/4134265希望这会有所帮助

标签: amazon-web-services amazon-s3 aws-cli


【解决方案1】:

尝试直接更改元数据:

aws s3 sync s3://${BUCKET_NAME} s3://${BUCKET_NAME}
--dryrun
--exclude '*'
--include '*.pdf'
--no-guess-mime-type
--metadata Content-Type=application/pdf

【讨论】:

    猜你喜欢
    • 2017-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-29
    • 2014-06-21
    • 1970-01-01
    • 2018-02-24
    • 2014-11-05
    相关资源
    最近更新 更多