Sha256: 86c2c1077e0cb8fff9f392f445062795febdf1b5d125f6ed46a10867d9cb0dae

Contents?: true

Size: 1.57 KB

Versions: 2

Compression:

Stored size: 1.57 KB

Contents

module Fog
  module Storage
    class Dtdream
      class Real
        # Get an expiring object https url from Cloud Files
        #
        # ==== Parameters
        # * container<~String> - Name of container containing object
        # * object<~String> - Name of object to get expiring url for
        # * expires<~Time> - An expiry time for this url
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~String> - url for object
        def get_object_https_url_public(object, expires, options = {})
          options = options.reject {|key, value| value.nil?}
          bucket = options[:bucket]
          bucket ||= @aliyun_oss_bucket
          acl = get_bucket_acl(bucket)
          location = get_bucket_location(bucket)
          
          if "private" == acl
            expires_time = (Time.now.to_i + expires).to_s
            resource = bucket+'/'+object
            signature = sign("GET", expires_time, nil, resource)
            url = "https://"+bucket+"."+location+".aliyuncs.com/"+object+
                     "?OSSAccessKeyId="+@aliyun_accesskey_id+"&Expires="+expires_time+
                     "&Signature="+URI.encode(signature,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
          elsif "public-read" == acl or "public-read-write" == acl
            url = "https://"+bucket+"."+location+".aliyuncs.com/"+object
          else
            url = "acl is wrong with value:"+acl
          end
        end
      end

      class Mock
        def get_object_https_url_public(object, expires, options = {})
          
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-dtdream-0.0.8 lib/fog/dtdream/requests/storage/get_object_https_url.rb
fog-dtdream-0.0.7 lib/fog/dtdream/requests/storage/get_object_https_url.rb