Sha256: 0b4a6127962d06abb5615e5c0abfc07cb90cbbd2a9493161c18a123e20f53cdd

Contents?: true

Size: 1.3 KB

Versions: 12

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

module Fog
  module Storage
    class Aliyun
      class Real
        # Copy object
        #
        # ==== Parameters
        # * source_bucket<~String> - Name of source bucket
        # * source_object<~String> - Name of source object
        # * target_bucket<~String> - Name of bucket to create copy in
        # * target_object<~String> - Name for new copy of object
        # * options<~Hash> - Additional headers options={}
        def copy_object(source_bucket, source_object, target_bucket, target_object, options = {})
          options = options.reject { |_key, value| value.nil? }
          bucket = options[:bucket]
          bucket ||= @aliyun_oss_bucket
          source_bucket ||= bucket
          target_bucket ||= bucket
          headers = { 'x-oss-copy-source' => "/#{source_bucket}/#{source_object}" }
          location = get_bucket_location(target_bucket)
          endpoint = 'http://' + location + '.aliyuncs.com'
          resource = target_bucket + '/' + target_object
          request(expects: [200, 203],
                  headers: headers,
                  method: 'PUT',
                  path: target_object,
                  bucket: target_bucket,
                  resource: resource,
                  endpoint: endpoint)
        end
      end
    end
  end
end

Version data entries

12 entries across 10 versions & 2 rubygems

Version Path
fog-aliyun-0.3.10 lib/fog/aliyun/requests/storage/copy_object.rb
fog-aliyun-0.3.9 lib/fog/aliyun/requests/storage/copy_object.rb
fog-aliyun-0.3.8 lib/fog/aliyun/requests/storage/copy_object.rb
fog-aliyun-0.3.7 lib/fog/aliyun/requests/storage/copy_object.rb
fog-aliyun-0.3.6 lib/fog/aliyun/requests/storage/copy_object.rb
fog-aliyun-0.3.5 lib/fog/aliyun/requests/storage/copy_object.rb
fog-aliyun-0.3.4 lib/fog/aliyun/requests/storage/copy_object.rb
fog-aliyun-0.3.3 lib/fog/aliyun/requests/storage/copy_object.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/requests/storage/copy_object.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/requests/storage/copy_object.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/requests/storage/copy_object.rb
fog-aliyun-0.3.2 lib/fog/aliyun/requests/storage/copy_object.rb