Sha256: eac8fee9413caac89b18d330a7afa96f4707a5f932242138684e2699e5299458

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

module Fog
  module Aliyun
    class Storage
      class Real
        # Get details for object
        #
        # ==== Parameters
        # * object_name<~String> - Name of object to look for
        #
        def get_object(bucket_name, object_name, options = {}, &block)
          options = options.reject { |_key, value| value.nil? }
          unless bucket_name
            raise ArgumentError.new('bucket_name is required')
          end
          unless object_name
            raise ArgumentError.new('object_name is required')
          end
          # Using OSS ruby SDK to fix performance issue
          http_options = { :headers => {} }
          http_options[:query] = options.delete('query') || {}

          http_options[:headers].merge!(options)
          if options['If-Modified-Since']
            http_options[:headers]['If-Modified-Since'] = Fog::Time.at(options['If-Modified-Since'].to_i).to_date_header
          end
          if options['If-Unmodified-Since']
            http_options[:headers]['If-Unmodified-Since'] = Fog::Time.at(options['If-Unmodified-Since'].to_i).to_date_header
          end

          if block_given?
            http_options[:response_block] = Proc.new {}
          end

          resources = {
              :bucket => bucket_name,
              :object => object_name
          }

          @oss_http.get(resources, http_options, &block)

        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-aliyun-0.4.0 lib/fog/aliyun/requests/storage/get_object.rb