相关疑难解决方法(0)

如何使用aws cli更改对象的内容类型?

我在Amazon S3中存储了几个对象,其内容类型我需要更改text/htmlapplication/rss+xml.我认为应该可以使用复制命令执行此操作,为源和目标指定相同的路径.我正在尝试使用AWS cli工具执行此操作,但我收到此错误:

$ aws s3 cp s3://mybucket/feed/ogg/index.html \
            s3://mybucket/feed/ogg/index.html \
            --content-type 'application/rss+xml'
copy failed: s3://mybucket/feed/ogg/index.html
to s3://mybucket/feed/ogg/index.html
A client error (InvalidRequest) occurred 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.
Run Code Online (Sandbox Code Playgroud)

如果我为源和目标指定不同的路径,我不会收到错误:

$ aws s3 cp s3://mybucket/feed/ogg/index.html \
            s3://mybucket/feed/ogg/index2.html \
            --content-type 'application/rss+xml'
copy: s3://mybucket/feed/ogg/index.html
to s3://mybucket/feed/ogg/index2.html
Run Code Online (Sandbox Code Playgroud)

即使命令成功完成,index2.html也会使用text/html内容类型创建对象,而不是 …

content-type command-line-interface amazon-s3 aws-cli

14
推荐指数
2
解决办法
9455
查看次数