Sha256: 260fe00295a16a1266d77127be54b0fe7715c77cc7c3ad077fb7c6b78ee376db

Contents?: true

Size: 1.21 KB

Versions: 31

Compression:

Stored size: 1.21 KB

Contents

module Fog
  module AWS
    class Storage
      class Real
        # Change tag set for an S3 object
        #
        # @param bucket_name [String] Name of bucket to modify object in
        # @param object_name [String] Name of object to modify
        #
        # @param tags [Hash]:
        #   * Key [String]: tag key
        #   * Value [String]: tag value
        #
        # @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectTagging.html

        def put_object_tagging(bucket_name, object_name, tags)
          tagging = tags.map do |k,v|
            "<Tag><Key>#{k}</Key><Value>#{v}</Value></Tag>"
          end.join("\n")
          data =
              <<-DATA
<Tagging xmlns="http://doc.s3.amazonaws.com/2006-03-01" >
  <TagSet>
    #{tagging}
  </TagSet>
</Tagging>
          DATA

          request({
            :body     => data,
            :expects  => 200,
            :headers  => {'Content-MD5' => Base64.encode64(OpenSSL::Digest::MD5.digest(data)).chomp!, 'Content-Type' => 'application/xml'},
            :bucket_name => bucket_name,
            :object_name => object_name,
            :method   => 'PUT',
            :query    => {'tagging' => nil}
          })
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
fog-aws-3.30.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.29.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.28.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.27.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.26.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.25.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.24.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.23.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.22.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.21.1 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.21.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.20.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.19.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.18.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.17.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.16.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.15.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.14.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.13.0 lib/fog/aws/requests/storage/put_object_tagging.rb
fog-aws-3.12.0 lib/fog/aws/requests/storage/put_object_tagging.rb