mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
refactor: duplicate parsing of the storage_uri, file#url uses service.create_temp_url to be able to pass options now
This commit is contained in:
parent
b7056383cb
commit
e30de086ca
2 changed files with 6 additions and 18 deletions
|
@ -68,8 +68,8 @@ module Fog
|
|||
# @param options [Hash]
|
||||
# @return [String] url
|
||||
def url(expires, options = {})
|
||||
requires :key
|
||||
self.collection.get_https_url(key, expires, options)
|
||||
requires :directory,:key
|
||||
service.create_temp_url(directory.key, key, expires, "GET", options)
|
||||
end
|
||||
|
||||
def cdn_public_url
|
||||
|
|
|
@ -217,19 +217,11 @@ module Fog
|
|||
end
|
||||
|
||||
expires = expires.to_i
|
||||
|
||||
# split up the storage uri
|
||||
uri = URI.parse(@hp_storage_uri)
|
||||
host = uri.host
|
||||
path = uri.path
|
||||
port = uri.port
|
||||
uri_scheme = uri.scheme
|
||||
|
||||
scheme = options[:scheme] || uri_scheme
|
||||
scheme = options[:scheme] || @scheme
|
||||
|
||||
# do not encode before signature generation, encode after
|
||||
sig_path = "#{path}/#{container}/#{object}"
|
||||
encoded_path = "#{path}/#{Fog::HP.escape(container)}/#{Fog::HP.escape(object)}"
|
||||
sig_path = "#{@path}/#{container}/#{object}"
|
||||
encoded_path = "#{@path}/#{Fog::HP.escape(container)}/#{Fog::HP.escape(object)}"
|
||||
|
||||
string_to_sign = "#{method}\n#{expires}\n#{sig_path}"
|
||||
|
||||
|
@ -254,11 +246,7 @@ module Fog
|
|||
end
|
||||
|
||||
# generate the temp url using the signature and expiry
|
||||
if scheme == "http"
|
||||
"#{scheme}://#{host}#{encoded_path}?temp_url_sig=#{signature}&temp_url_expires=#{expires}"
|
||||
else
|
||||
"#{scheme}://#{host}:#{port}#{encoded_path}?temp_url_sig=#{signature}&temp_url_expires=#{expires}"
|
||||
end
|
||||
"#{scheme}://#{@host}#{encoded_path}?temp_url_sig=#{signature}&temp_url_expires=#{expires}"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue