1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
module Fog
module Storage
class GoogleJSON
module Utils
def http_url(params, expires)
"http://" << host_path_query(params, expires)
end
def https_url(params, expires)
"https://" << host_path_query(params, expires)
end
def url(params, expires)
Fog::Logger.deprecation("Fog::Storage::Google => #url is deprecated, use #https_url instead [light_black](#{caller.first})[/]")
https_url(params, expires)
end
private
def host_path_query(params, expires)
params[:headers]["Date"] = expires.to_i
params[:path] = URI.encode(params[:path]).gsub("%2F", "/")
query = []
if params[:query]
filtered = params[:query].reject { |k, v| k.nil? || v.nil? }
query = filtered.map { |k, v| [k.to_s, Fog::Google.escape(v)].join("=") }
end
query << "GoogleAccessId=#{google_access_id}"
query << "Signature=#{CGI.escape(signature(params))}"
query << "Expires=#{params[:headers]['Date']}"
"#{params[:host]}/#{params[:path]}?#{query.join('&')}"
end
end
end
end
end
|