amazon-web-services - Add tag using s3.put_object
问题描述
I am using aws-sdk-core v2.2.37 as I cannot upgrade for various reasons.
Despite the documentation clearly showing that I can add a tag to the object with the "tagging" key.
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). 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.
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. The latest version is 2.11 but anything > 2.7 should include the S3 object tagging feature.
推荐阅读
- laravel - 多个表上的雄辩的自定义“属于”关系
- python - 在openCV中检测圆圈
- c++ - QApplication 在共享库中
- java - 如何让 ImageIcon 显示在 JButton 中?
- javascript - React TS - TypeWriter 组件
- laravel - Laravel - cache:clear 命令是否也会清除配置缓存?
- python - 如何验证请求正文是进入 python 烧瓶应用程序的有效 JSON
- spring-boot - 发送html电子邮件的问题
- automation - 空手道 UI 拖放
- ffmpeg - ffmpeg 图像生成输出结果