From 31cbf3a6fd7a133e89d5992ec9af83434cf17ee3 Mon Sep 17 00:00:00 2001 From: Liang Tao Date: Mon, 30 Jun 2014 16:08:46 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=92=88=E5=AF=B9?= =?UTF-8?q?=E4=B8=AD=E6=96=87Key=E7=9A=84=E7=A7=81=E6=9C=89=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E4=B8=8B=E8=BD=BDURL=E6=8E=88=E6=9D=83=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/qiniu/auth.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/qiniu/auth.rb b/lib/qiniu/auth.rb index 5a2a5f3..3d028ca 100755 --- a/lib/qiniu/auth.rb +++ b/lib/qiniu/auth.rb @@ -3,6 +3,7 @@ require 'hmac-sha1' require 'uri' +require 'cgi' require 'qiniu/exceptions' @@ -175,6 +176,12 @@ module Qiniu return "#{download_url}&token=#{dntoken}" 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}" + return authorize_download_url(download_url, args) + end # authorize_download_url_2 + def generate_acctoken(url, body = '') ### 提取AK/SK信息 access_key = Config.settings[:access_key] From 1222559c71ad3f425162064fa142b19d8d3a3050 Mon Sep 17 00:00:00 2001 From: Liang Tao Date: Tue, 1 Jul 2014 11:57:45 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20schema=20=E5=92=8C=20p?= =?UTF-8?q?ort=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 From 58dfe18328edc79b6db818735236cb41a228a262 Mon Sep 17 00:00:00 2001 From: Liang Tao Date: Tue, 1 Jul 2014 14:40:48 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20authorize=5Fdownload?= =?UTF-8?q?=5Furl=5F2=20=E6=96=B9=E6=B3=95=EF=BC=8C=E5=AF=B9=E5=8C=85?= =?UTF-8?q?=E5=90=AB=E4=B8=AD=E6=96=87=E6=88=96=E5=85=B6=E5=AE=83=20utf-8?= =?UTF-8?q?=20=E5=AD=97=E7=AC=A6=E7=9A=84Key=E5=81=9A=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/qiniu/auth.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/qiniu/auth.rb b/lib/qiniu/auth.rb index b552d62..c880d07 100755 --- a/lib/qiniu/auth.rb +++ b/lib/qiniu/auth.rb @@ -176,6 +176,7 @@ module Qiniu return "#{download_url}&token=#{dntoken}" end # authorize_download_url + ### 对包含中文或其它 utf-8 字符的 Key 做下载授权 def authorize_download_url_2(domain, key, args = EMPTY_ARGS) url_encoded_key = CGI::escape(key) From 5ffe9daf582cbcc0cade9ede6d04f7521fc293bd Mon Sep 17 00:00:00 2001 From: Liang Tao Date: Tue, 1 Jul 2014 15:27:35 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ Gemfile.lock | 2 +- README.md | 2 +- lib/qiniu/version.rb | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd00fed..f738dcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## CHANGE LOG +### v6.3.0 + +- 添加 authorize_download_url_2 方法,对包含中文或其它 utf-8 字符的 Key 做下载授权。 [https://github.com/qiniu/ruby-sdk/pull/95](https://github.com/qiniu/ruby-sdk/pull/95) + ### v6.2.4 - 调整User Agent。 [https://github.com/qiniu/ruby-sdk/pull/94](https://github.com/qiniu/ruby-sdk/pull/94) diff --git a/Gemfile.lock b/Gemfile.lock index e83b991..069dbbc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - qiniu (6.2.4) + qiniu (6.3.0) json (~> 1.7) mime-types (~> 1.19) rest-client (~> 1.6) diff --git a/README.md b/README.md index 51e2dde..ffa495b 100755 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ 在您 Ruby 应用程序的 `Gemfile` 文件中,添加如下一行代码: - gem 'qiniu', '~> 6.2.0' + gem 'qiniu', '~> 6.3.0' 然后,在应用程序所在的目录下,可以运行 `bundle` 安装依赖包: diff --git a/lib/qiniu/version.rb b/lib/qiniu/version.rb index efd4b95..2d26240 100755 --- a/lib/qiniu/version.rb +++ b/lib/qiniu/version.rb @@ -3,8 +3,8 @@ module Qiniu module Version MAJOR = 6 - MINOR = 2 - PATCH = 4 + MINOR = 3 + PATCH = 0 # Returns a version string by joining MAJOR, MINOR, and PATCH with '.' # # Example