S3API:删除对象元数据

时间:2020-06-30 22:46:22

标签: amazon-web-services amazon-s3

我跑步时

To change the IDENTITY property of a column, the column needs to be dropped and recreated

我得到两行输出:

aws s3api head-object --bucket models.huggingface.co --key bert/Helsinki-NLP/opus-mt-en-ROMANCE/config.json

是否可以通过编程方式在S3上删除此元数据?这样,如果我再次运行get命令,将不会收到元数据?

1 个答案:

答案 0 :(得分:0)

您的问题格式存在问题。尽管如此,head-object返回以下结构(示例):

{
    "AcceptRanges": "bytes",
    "ContentType": "text/html",
    "LastModified": "Thu, 16 Apr 2015 18:19:14 GMT",
    "ContentLength": 77,
    "VersionId": "null",
    "ETag": "\"30a6ec7e1a9ad79c203d05a589c8b400\"",
    "Metadata": {}
}

因此,要删除Metadata,可以使用jq,如下所示:

aws s3api head-object \
    --bucket models.huggingface.co \
    --key bert/Helsinki-NLP/opus-mt-en-ROMANCE/config.json \
    | jq -M 'del(.Metadata)'

应产生(示例)的

{
    "AcceptRanges": "bytes",
    "ContentType": "text/html",
    "LastModified": "Thu, 16 Apr 2015 18:19:14 GMT",
    "ContentLength": 77,
    "VersionId": "null",
    "ETag": "\"30a6ec7e1a9ad79c203d05a589c8b400\""
}