Sha256: 4db21ced87a8f838d3b51ecce5858802c90122c6b215b36f5b0dadc50ddad21b

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

module Fog
  module Storage
    class Aliyun
      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 acl == 'private'
            expires_time = (Time.now.to_i + expires).to_s
            resource = bucket + '/' + object
            signature = sign('GET', expires_time, nil, resource)
            'https://' + bucket + '.' + location + '.aliyuncs.com/' + object +
              '?OSSAccessKeyId=' + @aliyun_accesskey_id + '&Expires=' + expires_time +
              '&Signature=' + URI.encode(signature, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
          elsif acl == 'public-read' || acl == 'public-read-write'
            'https://' + bucket + '.' + location + '.aliyuncs.com/' + object
          else
            'acl is wrong with value:' + acl
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 2 versions & 2 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/requests/storage/get_object_https_url.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/requests/storage/get_object_https_url.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/requests/storage/get_object_https_url.rb
fog-aliyun-0.3.2 lib/fog/aliyun/requests/storage/get_object_https_url.rb