首页 > 解决方案 > 为什么没有将用户定义的元数据添加到对象(aws s3api put-object?

问题描述

我一直在尝试创建一个存储桶,然后创建一个内部包含用户定义元数据的对象。为此,我执行了以下命令(或它的关闭变体):

aws s3api create-bucket --bucket mybucket1

aws s3api put-object --bucket mybucket1 \
                     --key mykey1 \
                     --body test_files/test-pattern-152459_960_720.png \
                     --metadata '{"x-amz-meta-author":"Test"}'

但是,当我尝试使用命令从对象中检索元数据时

aws s3api head-object --bucket mybucket1 --key mykey1

用户定义的元数据始终为空:

{
    "ContentType": "binary/octet-stream",
    "LastModified": "Fri, 12 Nov 2021 12:01:17 GMT",
    "ContentLength": 18062,
    "Expires": "Fri, 12 Nov 2021 12:01:27 GMT",
    "ETag": "2021-11-12T12:01:17.457Z",
    "CacheControl": "no-cache",
    "Metadata": {}
}

这些命令没有给出任何错误,但它就像某些选项一样被完全忽略了。我还尝试使用以下命令创建/更新对象:

awks s3api head-object --cli-input-json '{...}'

我省略了 json 以避免混乱,但我严格遵循通过“--generate-cli-skeleton”选项生成的模板。结果与上面相同:我无法向元数据添加任何内容,也无法更改 ContentType 字段。我还尝试将 alc 修改为 public-read-write,但没有任何改变。

我忽略了什么吗?我看不出我做错了什么。

“放置对象”文档页面:https ://docs.aws.amazon.com/cli/latest/reference/s3api/put-object.html

标签: amazon-web-servicesamazon-s3aws-cli

解决方案


Your awscli version is 1.14.28, dated January 2018. That's almost 4 years old. I tested with an up to date v2 awscli and this worked correctly.

I think you should install the latest awscli and re-test.

Whether or not Apache Ozone's S3 API implementation actually supports custom metadata is not clear. Their S3 API docs don't give any details on how compatible their PUT/HEAD emulation is.


推荐阅读