Add tags to an existing S3 object using the ruby AWS SDK

Viewed 277
1 Answers

OK, answering my question, I eventually found a method on Aws::S3::Client

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

s3_client = Aws::S3::Client.new
s3_client.put_object_tagging({
                bucket: "bucket_name",
                key: "some/key.jpg",
                tagging: {
                  tag_set: [
                    {
                      key: "tag-name",
                      value: "tag value",
                    }
                  ]
                }
})

i was expecting there to be a method on Aws::S3::Bucket or Aws::S3::Object, but if there is I can't figure it out! But I have verified this one on Aws::S3::Client as working for me.

Related