简体   繁体   English

如何将 object 标签放在现有标签 object 上

[英]How to put object tags on existing tagged object

I am currently developing Lambda functions using NodeJS and AWS S3 SDK.我目前正在使用 NodeJS 和 AWS S3 SDK 开发 Lambda 函数。

While working local with serverless offline, I can easily replace an object TagSet with putObjectTagging function, but in Production environment, I do have this error:在本地使用无服务器离线工作时,我可以轻松地将 object TagSet 替换为putObjectTagging function,但在生产环境中,我确实遇到此错误:

Cannot provide multiple Tags with the same key不能提供具有相同键的多个标签

While reading putObjectTagging and AWS tags documentation, I do not find any solution for this error because I do presume that putObjectTagging replace all tags of an existing object.在阅读putObjectTagging和 AWS 标签文档时,我没有找到针对此错误的任何解决方案,因为我确实假设putObjectTagging替换了现有 object 的所有标签。

In my code, I get the existing TagSet and update the values, then put them:在我的代码中,我获取现有的 TagSet 并更新值,然后将它们放入:

let tags = await S3.getObjectTagging(bucketParam).promise();
// process on tags and set in paramsPutObjectTagging
await S3.putObjectTagging(paramsPutObjectTagging).promise();

Thank you in advance, Regards.提前谢谢你, 问候。

The s3:PutObjectTagging call will replace any existing TagSet on the object with the TagSet provided in the call. s3:PutObjectTagging调用将用调用中提供的 TagSet 替换TagSet上的任何现有TagSet Although the TagSet attribute in the request body for the call is an array, the Key attribute of every item in the array must be distinct, you cannot have duplicate Key s in the TagSet .虽然调用请求体中的TagSet属性是一个数组,但是数组中每一项的Key属性必须是不同的, TagSet中不能有重复的Key

To add a new tag to an object whilst preserving the existing tags that are there you need to retrieve the existing TagSet using s3:GetObjectTagging , then append the new tag to the TagSet array, then use s3:PutObjectTagging as described above.要向 object 添加新标签,同时保留现有标签,您需要使用s3:GetObjectTagging检索现有TagSet ,然后 append 将新标签添加到TagSet数组,然后如上所述使用s3:PutObjectTagging When doing this you need to check that there isn't already a tag in the TagSet retrieved from s3:GetObjectTagging with the same Key as the new tag you're trying to add - this is likely to be why you are getting that error.执行此操作时,您需要检查从s3:GetObjectTagging检索到的TagSet中是否还没有与您尝试添加的新标签具有相同Key的标签 - 这可能就是您收到该错误的原因。

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

相关问题 如何用Pulumi导入已有的S3 object? - How to import an existing S3 object with Pulumi? 如何以编程方式将 object 放入 firebase 数据库中的另一个 object 中? - How to put an object inside another object in firebase database programmatically? 无法从现有标记的 JSON 文件创建自定义 NER 项目 - Not able to create Custom NER Project from existing tagged JSON file 如何使用预签名的 URL 以及 s3 aws-sdk-ruby v3 中的标签上传 object - How to upload an object using presigned URL along with tags in s3 aws-sdk-ruby v3 如何在不使用 AWS CLI 删除现有标签的情况下将标签添加到 S3 存储桶? - How to add tags to an S3 Bucket without deleting the existing tags using AWS CLI? 如何在 firebase 9 中的现有 object 中添加新键和值而不覆盖以前的数据 - how to add a new key and value to an existing object in firebase 9 without overwriting previous data 如何将标签添加到 ECS 现有服务,使用 Terraform 定义任务 - How to add Tags to ECS existing Service, Task definition using Terraform 在通过 aws cli 上传期间将多个标签应用于 object - Apply multiple tags to an object during uploading via aws cli AWS S3 的 getSignedUrl for put object 返回 403 - AWS S3's getSignedUrl for put object returns 403 无法使用在 Greengrass 上运行的 aws lambda 将 object 放入 S3 - Cannot put object to S3 using aws lambda running on Greengrass
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM