From 1222559c71ad3f425162064fa142b19d8d3a3050 Mon Sep 17 00:00:00 2001 From: Liang Tao Date: Tue, 1 Jul 2014 11:57:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20schema=20=E5=92=8C=20port?= =?UTF-8?q?=20=E5=8F=82=E6=95=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/qiniu/auth.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/qiniu/auth.rb b/lib/qiniu/auth.rb index 3d028ca..b552d62 100755 --- a/lib/qiniu/auth.rb +++ b/lib/qiniu/auth.rb @@ -177,8 +177,16 @@ module Qiniu end # authorize_download_url def authorize_download_url_2(domain, key, args = EMPTY_ARGS) - url_encoded_key = key.split('/').map{|x| CGI::escape(x)}.join("/") - download_url = "http://#{domain}/#{url_encoded_key}" + url_encoded_key = CGI::escape(key) + + schema = args[:schema] || "http" + port = args[:port] + + if port.nil? then + download_url = "#{schema}://#{domain}/#{url_encoded_key}" + else + download_url = "#{schema}://#{domain}:#{port}/#{url_encoded_key}" + end return authorize_download_url(download_url, args) end # authorize_download_url_2