Sha256: 3e2ccef3841f6f0b49a88ad8884973692dbc05a19d9a63aa00fcc947cefd1789

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module Fog
  module Storage
    class Aliyun
      class Real
        # Get details for object
        #
        # ==== Parameters
        # * object<~String> - Name of object to look for
        #
        def get_object(object, range = nil, options = {})
          options = options.reject { |_key, value| value.nil? }
          bucket = options[:bucket]
          bucket ||= @aliyun_oss_bucket
          endpoint = options[:endpoint]
          if endpoint.nil?
            location = get_bucket_location(bucket)
            endpoint = 'http://' + location + '.aliyuncs.com'
          end
          resource = bucket + '/' + object
          para = {
            expects: [200, 206, 404],
            method: 'GET',
            path: object,
            bucket: bucket,
            resource: resource,
            endpoint: endpoint
          }

          if range
            rangeStr = 'bytes=' + range
            para[:headers] = { 'Range' => rangeStr }
          end

          response = request(para)
          response.data
        end
      end

      class Mock
        def get_object(object, range = nil, options = {}); end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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