nel*_*rom 14 content-type command-line-interface amazon-s3 aws-cli
我在Amazon S3中存储了几个对象,其内容类型我需要更改text/html
为application/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
内容类型创建对象,而不是application/rss+xml
我指定的类型.
如何修改此命令行以使其工作?
Caw*_*b07 11
可以使用低级别s3api
进行此更改:
$ aws s3api copy-object --bucket archive --content-type "application/rss+xml" \
--copy-source archive/test/test.html --key test/test.html \
--metadata-directive "REPLACE"
Run Code Online (Sandbox Code Playgroud)
http://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html
问题是无法指定--metadata-directive
.感谢您指出公开的问题/功能请求,nelstrom!
您还可以使用更高级别的 API 来实现,方法是将文件复制到其自身,但将其标记为元数据的更改:
aws s3 cp \
--content-type "application/rss+xml" \
--metadata-directive REPLACE \
s3://mybucket/myfile \
s3://mybucket/myfile
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9455 次 |
最近记录: |