简体   繁体   English

使用 s3.put_object 添加标签

[英]Add tag using s3.put_object

I am using aws-sdk-core v2.2.37 as I cannot upgrade for various reasons.我正在使用 aws-sdk-core v2.2.37,因为由于各种原因我无法升级。

Despite the documentation clearly showing that I can add a tag to the object with the "tagging" key.尽管文档清楚地表明我可以使用“标记”键向 object 添加标记。

https://docs.aws.amazon.com/sdk-for-ruby/v2/api/Aws/S3/Client.html#put_object-instance_method https://docs.aws.amazon.com/sdk-for-ruby/v2/api/Aws/S3/Client.html#put_object-instance_method

The code,编码,

resp = s3.put_object(
{
    bucket:"osworkerfiles",
    key:"testingtags457",
    body:"testing123456",
    tagging:"key1=value1"
})

Edit: I have also tried "tags"编辑:我也尝试过“标签”

always returns总是返回

在此处输入图像描述

The request without the tagging key works - is there something I am doing wrong here?没有标记密钥的请求有效 - 我在这里做错了什么吗?

The version of the SDK you are using ( v2.2.37 ) is 5 years old (April 2016).您使用的 SDK 版本 ( v2.2.37 ) 已有 5 年历史(2016 年 4 月)。 Object tagging in S3 wasn't released until December of 2016 so the version of the SDK you are using doesn't have this feature enabled yet. S3 中的 Object 标记直到 2016 年 12 月才发布,因此您使用的 SDK 版本尚未启用此功能。

Even if you can't use v3 of the SDK, you'll at least need to upgrade to a more recently version of the v2 SDK.即使您不能使用 SDK 的 v3,您也至少需要升级到最新版本的 v2 SDK。 The latest version is 2.11 but anything > 2.7 should include the S3 object tagging feature.最新版本是 2.11,但任何大于 2.7 的版本都应包含 S3 object 标记功能。

Reference: https://rubygems.org/gems/aws-sdk-core/versions参考: https://rubygems.org/gems/aws-sdk-core/versions

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM