qiniu 6.2.4 → 6.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 349b796d9306147e929b2091445051f591cd2df1
4
- data.tar.gz: 343159ae0e4736a2e7c720d21a8d86535d3acd20
3
+ metadata.gz: 0490995fd65a7c080576f274603413605c3fad33
4
+ data.tar.gz: 2c9cfb656b7f522af8f12b6de04b11e7cbc12ce9
5
5
  SHA512:
6
- metadata.gz: d92d87c525d88f9a598d16dcbc092a8ccf39812bc003d81e66f49382ef2686cf50232c719d6de616194ae77d190ec19a1043d0eac7178723ad09e7cfb2de5277
7
- data.tar.gz: b71fdc23e374c5e69ba1fe6884a6a54d6e044d0ea1dccda4ac93d28e45f2f7207e98eee7a50b3da37e6d252157bfe1e5617421805674f7364bf10993f3b35a70
6
+ metadata.gz: f7ee45929fd260b772ff70f9629c27bf4e1beb22c323e0c3d3859910397857a2a2773e8ef1835f2e0b9e1b6ccd7aa5ee379f596f52828572057cd1703f33d130
7
+ data.tar.gz: 60e62061df61c91562f6be6242df8c15b011a71392fbdc6c1fd7635f60794d901d276cf028b3790e84bca79f2a4d736c83b1727798831ce4246b7bc43a903d2b
data/.travis.yml CHANGED
@@ -5,5 +5,5 @@ rvm:
5
5
  - 2.1.1
6
6
  - jruby-19mode
7
7
  before_script:
8
- - export QINIU_ACCESS_KEY=LGRqJsjX7LAvtdtX6hhyxs861lS57HwnOQmJsOuX
9
- - export QINIU_SECRET_KEY=g_OxhuN5iJ1O7BoA6YdXyF6zSszk34UZFKDfdIIW
8
+ - export QINIU_ACCESS_KEY=QWYn5TFQsLLU1pL5MFEmX3s5DmHdUThav9WyOWOm
9
+ - export QINIU_SECRET_KEY=Bxckh6FA-Fbs9Yt3i3cbKVK22UPBmAOHJcL95pGz
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  ## CHANGE LOG
2
2
 
3
+ ### v6.3.2
4
+
5
+ - 调整上传host。 [https://github.com/qiniu/ruby-sdk/pull/103](https://github.com/qiniu/ruby-sdk/pull/103)
6
+
7
+ ### v6.3.1
8
+
9
+ - 为过期方法添加说明。 [https://github.com/qiniu/ruby-sdk/pull/98](https://github.com/qiniu/ruby-sdk/pull/98)
10
+ - 修改上传域名。 [https://github.com/qiniu/ruby-sdk/pull/99](https://github.com/qiniu/ruby-sdk/pull/99)
11
+ - 增加pfop参数。 [https://github.com/qiniu/ruby-sdk/pull/100](https://github.com/qiniu/ruby-sdk/pull/100)
12
+
13
+ ### v6.3.0
14
+
15
+ - 添加 authorize_download_url_2 方法,对包含中文或其它 utf-8 字符的 Key 做下载授权。 [https://github.com/qiniu/ruby-sdk/pull/95](https://github.com/qiniu/ruby-sdk/pull/95)
16
+
3
17
  ### v6.2.4
4
18
 
5
19
  - 调整User Agent。 [https://github.com/qiniu/ruby-sdk/pull/94](https://github.com/qiniu/ruby-sdk/pull/94)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qiniu (6.2.4)
4
+ qiniu (6.3.1)
5
5
  json (~> 1.7)
6
6
  mime-types (~> 1.19)
7
7
  rest-client (~> 1.6)
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## 关于
4
4
 
5
- 此 Ruby SDK 适用于 Ruby 1.8.x, 1.9.x, 2.0.x, jruby, rbx, ree 版本,基于 [七牛云存储官方API](http://developer.qiniu.com/docs/v6/index.html) 构建。使用此 SDK 构建您的网络应用程序,能让您以非常便捷地方式将数据安全地存储到七牛云存储上。无论您的网络应用是一个网站程序,还是包括从云端(服务端程序)到终端(手持设备应用)的架构的服务或应用,通过七牛云存储及其 SDK,都能让您应用程序的终端用户高速上传和下载,同时也让您的服务端更加轻盈。
5
+ 此 Ruby SDK 适用于 Ruby 1.9.x, 2.0.x, 2.1.x, jruby版本,基于 [七牛云存储官方API](http://developer.qiniu.com/docs/v6/index.html) 构建。使用此 SDK 构建您的网络应用程序,能让您以非常便捷地方式将数据安全地存储到七牛云存储上。无论您的网络应用是一个网站程序,还是包括从云端(服务端程序)到终端(手持设备应用)的架构的服务或应用,通过七牛云存储及其 SDK,都能让您应用程序的终端用户高速上传和下载,同时也让您的服务端更加轻盈。
6
6
 
7
7
  ## 状态
8
8
 
@@ -15,7 +15,7 @@
15
15
 
16
16
  在您 Ruby 应用程序的 `Gemfile` 文件中,添加如下一行代码:
17
17
 
18
- gem 'qiniu', '~> 6.1.0'
18
+ gem 'qiniu', '~> 6.3.1'
19
19
 
20
20
  然后,在应用程序所在的目录下,可以运行 `bundle` 安装依赖包:
21
21
 
data/lib/qiniu/auth.rb CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  require 'hmac-sha1'
5
5
  require 'uri'
6
+ require 'cgi'
6
7
 
7
8
  require 'qiniu/exceptions'
8
9
 
@@ -175,6 +176,21 @@ module Qiniu
175
176
  return "#{download_url}&token=#{dntoken}"
176
177
  end # authorize_download_url
177
178
 
179
+ ### 对包含中文或其它 utf-8 字符的 Key 做下载授权
180
+ def authorize_download_url_2(domain, key, args = EMPTY_ARGS)
181
+ url_encoded_key = CGI::escape(key)
182
+
183
+ schema = args[:schema] || "http"
184
+ port = args[:port]
185
+
186
+ if port.nil? then
187
+ download_url = "#{schema}://#{domain}/#{url_encoded_key}"
188
+ else
189
+ download_url = "#{schema}://#{domain}:#{port}/#{url_encoded_key}"
190
+ end
191
+ return authorize_download_url(download_url, args)
192
+ end # authorize_download_url_2
193
+
178
194
  def generate_acctoken(url, body = '')
179
195
  ### 提取AK/SK信息
180
196
  access_key = Config.settings[:access_key]
data/lib/qiniu/config.rb CHANGED
@@ -20,7 +20,7 @@ module Qiniu
20
20
  :content_type => 'application/x-www-form-urlencoded',
21
21
  :auth_url => "https://acc.qbox.me/oauth2/token",
22
22
  :rs_host => "http://rs.qiniu.com",
23
- :up_host => "http://up.qiniu.com",
23
+ :up_host => "http://upload.qiniu.com",
24
24
  :pub_host => "http://pu.qbox.me:10200",
25
25
  :eu_host => "http://eu.qbox.me",
26
26
  :access_key => "",
@@ -14,22 +14,6 @@ module Qiniu
14
14
  return HTTP.management_post(url)
15
15
  end # buckets
16
16
 
17
- PRIVATE_BUCKET = 0
18
- PUBLIC_BUCKET = 1
19
-
20
- def mkbucket(bucket_name, is_public = PUBLIC_BUCKET)
21
- url = Config.settings[:rs_host] + '/mkbucket2/' + bucket_name + '/public/' + is_public.to_s
22
- return HTTP.management_post(url)
23
- end # mkbucket
24
-
25
- def make_a_private_bucket(bucket_name)
26
- return mkbucket(bucket_name, PRIVATE_BUCKET)
27
- end # make_a_private_bucket
28
-
29
- def make_a_public_bucket(bucket_name)
30
- return mkbucket(bucket_name, PUBLIC_BUCKET)
31
- end # make_a_public_bucket
32
-
33
17
  def stat(bucket, key)
34
18
  url = Config.settings[:rs_host] + '/stat/' + encode_entry_uri(bucket, key)
35
19
  return HTTP.management_post(url)
@@ -60,11 +44,6 @@ module Qiniu
60
44
  return HTTP.management_post(url)
61
45
  end # delete
62
46
 
63
- def drop(bucket)
64
- url = Config.settings[:rs_host] + "/drop/#{bucket}"
65
- return HTTP.management_post(url)
66
- end # drop
67
-
68
47
  def batch(command, bucket, keys)
69
48
  execs = []
70
49
  keys.each do |key|
@@ -117,9 +96,9 @@ module Qiniu
117
96
 
118
97
  def _batch_cp_or_mv(command, *op_args)
119
98
  execs = []
120
- op_args.each do |e|
99
+ op_args.each do |e|
121
100
  execs << 'op=' + _generate_cp_or_mv_opstr(command, e[0], e[1], e[2], e[3]) if e.size == 4
122
- end
101
+ end
123
102
  url = Config.settings[:rs_host] + "/batch"
124
103
  return HTTP.management_post(url, execs.join("&"))
125
104
  end # _batch_cp_or_mv
@@ -4,6 +4,8 @@ require 'hmac-sha1'
4
4
  require 'qiniu/config'
5
5
  require 'qiniu/utils'
6
6
 
7
+ ### AccessToken 类已经过时,请改用 Qiniu::Auth.generate_acctoken 方法 ###
8
+
7
9
  module Qiniu
8
10
  class AccessToken
9
11
 
@@ -4,6 +4,9 @@ require 'json'
4
4
  require 'qiniu/tokens/access_token'
5
5
  require 'qiniu/utils'
6
6
 
7
+ ### DownloadToken 类已经过时,请改用 Qiniu::Auth.authorize_download_url 方法 ###
8
+ ### 或 Qiniu::Auth.authorize_download_url_2 方法 ###
9
+
7
10
  module Qiniu
8
11
  class DownloadToken < AccessToken
9
12
 
@@ -4,6 +4,8 @@ require 'json'
4
4
  require 'qiniu/tokens/access_token'
5
5
  require 'qiniu/utils'
6
6
 
7
+ ### UploadToken 类已经过时,请改用 Qiniu::Auth.generate_uptoken 方法 ###
8
+
7
9
  module Qiniu
8
10
  class UploadToken < AccessToken
9
11
 
@@ -19,7 +21,9 @@ module Qiniu
19
21
  @callback_body_type = opts[:callback_body_type]
20
22
  @customer = opts[:customer]
21
23
  @escape = opts[:escape]
22
- @async_options = opts[:async_options]
24
+ @persistent_ops = opts[:persistent_ops]
25
+ @persistent_notify_url = opts[:persistent_notify_url]
26
+ @persistent_pipeline = opts[:persistent_pipeline]
23
27
  @return_body = opts[:return_body]
24
28
  @return_url = opts[:return_url]
25
29
  end
@@ -31,9 +35,13 @@ module Qiniu
31
35
  params[:callbackBodyType] = @callback_body_type if !@callback_body_type.nil? && !@callback_body_type.empty?
32
36
  params[:customer] = @customer if !@customer.nil? && !@customer.empty?
33
37
  params[:escape] = 1 if @escape == 1 || @escape == true
34
- params[:asyncOps] = @async_options if !@async_options.nil? && !@async_options.empty?
35
38
  params[:returnBody] = @return_body if !@return_body.nil? && !@return_body.empty?
36
39
  params[:returnUrl] = @return_url if !@return_url.nil? && !@return_url.empty?
40
+
41
+ params[:persistentOps] = @persistent_ops if !@persistent_ops.nil? && !@persistent_ops.empty?
42
+ params[:persistentNotifyUrl] = @persistent_notify_url if !@persistent_notify_url.nil? && !@persistent_notify_url.empty?
43
+ params[:persistentPipeline] = @persistent_pipeline if !@persistent_pipeline.nil? && !@persistent_pipeline.empty?
44
+
37
45
  Utils.urlsafe_base64_encode(params.to_json)
38
46
  end
39
47
 
data/lib/qiniu/version.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  module Qiniu
4
4
  module Version
5
5
  MAJOR = 6
6
- MINOR = 2
7
- PATCH = 4
6
+ MINOR = 3
7
+ PATCH = 2
8
8
  # Returns a version string by joining <tt>MAJOR</tt>, <tt>MINOR</tt>, and <tt>PATCH</tt> with <tt>'.'</tt>
9
9
  #
10
10
  # Example
@@ -7,20 +7,13 @@ require 'qiniu/storage'
7
7
  require 'digest/sha1'
8
8
 
9
9
  module Qiniu
10
- module Auth
10
+ module Auth
11
11
  describe Auth do
12
12
 
13
13
  before :all do
14
- @bucket = 'RubySDK-Test-Private'
15
- @bucket = make_unique_bucket(@bucket)
16
-
17
- ### 尝试创建Bucket
18
- result = Qiniu::Storage.make_a_private_bucket(@bucket)
19
- puts result.inspect
14
+ @bucket = 'rubysdk'
20
15
  end
21
-
22
16
  after :all do
23
- ### 不删除Bucket以备下次使用
24
17
  end
25
18
 
26
19
  ### 测试私有资源下载
@@ -10,15 +10,7 @@ module Qiniu
10
10
  describe Fop do
11
11
 
12
12
  before :all do
13
-
14
- ### 复用RubySDK-Test-Storage空间
15
- @bucket = 'RubySDK-Test-Storage'
16
- @bucket = make_unique_bucket(@bucket)
17
-
18
- ### 尝试创建空间
19
- result = Qiniu.mkbucket(@bucket)
20
- puts result.inspect
21
-
13
+ @bucket = 'rubysdk'
22
14
  pic_fname = "image_logo_for_test.png"
23
15
  @key = make_unique_key_in_bucket(pic_fname)
24
16
 
@@ -57,7 +49,6 @@ module Qiniu
57
49
  end
58
50
 
59
51
  after :all do
60
- ### 不删除Bucket以备下次使用
61
52
  end
62
53
 
63
54
  context ".info" do
@@ -12,12 +12,7 @@ module Qiniu
12
12
  describe Storage do
13
13
 
14
14
  before :all do
15
- @bucket = 'RubySDK-Test-Management'
16
- @bucket = make_unique_bucket(@bucket)
17
-
18
- ### 尝试创建Bucket
19
- result = Qiniu.mkbucket(@bucket)
20
- puts result.inspect
15
+ @bucket = 'rubysdk'
21
16
 
22
17
  @key = Digest::SHA1.hexdigest((Time.now.to_i+rand(100)).to_s)
23
18
  @key = make_unique_key_in_bucket(@key)
@@ -26,7 +21,6 @@ module Qiniu
26
21
  end
27
22
 
28
23
  after :all do
29
- ### 不删除Bucket以备下次使用
30
24
  end
31
25
 
32
26
  ### 准备数据
@@ -10,16 +10,10 @@ module Qiniu
10
10
  describe Misc do
11
11
 
12
12
  before :all do
13
- ### 复用RubySDK-Test-Management空间
14
- @bucket = 'RubySDK-Test-Management'
15
- @bucket = make_unique_bucket(@bucket)
16
-
17
- result = Qiniu.mkbucket(@bucket)
18
- puts result.inspect
13
+ @bucket = 'rubysdk'
19
14
  end
20
15
 
21
16
  after :all do
22
- ### 不删除Bucket以备下次使用
23
17
  end
24
18
 
25
19
  context ".set_protected" do
@@ -12,15 +12,7 @@ module Qiniu
12
12
  describe Persistance do
13
13
 
14
14
  before :all do
15
- ### 复用RubySDK-Test-Storage空间
16
- @bucket = 'RubySDK-Test-Storage'
17
- @bucket = make_unique_bucket(@bucket)
18
-
19
- ### 尝试创建空间
20
- code, data, headers = Qiniu::Storage.make_a_public_bucket(@bucket)
21
- puts code.inspect
22
- puts data.inspect
23
- puts headers.inspect
15
+ @bucket = 'rubysdk'
24
16
 
25
17
  pic_fname = "image_logo_for_test.png"
26
18
  @key = make_unique_key_in_bucket(pic_fname)
@@ -44,7 +36,6 @@ module Qiniu
44
36
  end
45
37
 
46
38
  after :all do
47
- ### 不删除Bucket以备下次使用
48
39
  end
49
40
 
50
41
  context ".pfop" do
@@ -9,15 +9,10 @@ module Qiniu
9
9
  describe Qiniu do
10
10
 
11
11
  before :all do
12
- @bucket = 'RubySDK-Test'
13
- @bucket = make_unique_bucket(@bucket)
12
+ @bucket = 'rubysdk'
14
13
 
15
14
  @test_image_bucket = @bucket
16
15
 
17
- ### 尝试创建Bucket
18
- result = Qiniu.mkbucket(@bucket)
19
- puts result.inspect
20
-
21
16
  @key = Digest::SHA1.hexdigest Time.now.to_s
22
17
  @key = make_unique_key_in_bucket(@key)
23
18
 
@@ -34,7 +29,6 @@ module Qiniu
34
29
  end
35
30
 
36
31
  after :all do
37
- ### 不删除Bucket以备下次使用
38
32
  end
39
33
 
40
34
  context ".buckets" do
@@ -11,12 +11,7 @@ module Qiniu
11
11
  describe Storage do
12
12
 
13
13
  before :all do
14
- @bucket = 'RubySDK-Test-Storage'
15
- @bucket = make_unique_bucket(@bucket)
16
-
17
- ### 尝试创建Bucket
18
- result = Qiniu.mkbucket(@bucket)
19
- puts result.inspect
14
+ @bucket = 'rubysdk'
20
15
 
21
16
  @key = Digest::SHA1.hexdigest((Time.now.to_i+rand(100)).to_s)
22
17
  @key = make_unique_key_in_bucket(@key)
@@ -53,8 +48,6 @@ module Qiniu
53
48
  File.unlink(@localfile_4m) if File.exists?(@localfile_4m)
54
49
  File.unlink(@localfile_8m) if File.exists?(@localfile_8m)
55
50
  File.unlink(@localfile_1m) if File.exists?(@localfile_1m)
56
-
57
- ### 不删除Bucket以备下次使用
58
51
  end
59
52
 
60
53
  ### 测试单文件直传
@@ -26,8 +26,8 @@ module Qiniu
26
26
  context ".send_request_with" do
27
27
  it "should works" do
28
28
  FakeWeb.allow_net_connect = false
29
- FakeWeb.register_uri(:get, "http://docs.qiniutek.com/", :body => {:abc => 123}.to_json)
30
- res = Utils.send_request_with 'http://docs.qiniutek.com/', nil, :method => :get
29
+ FakeWeb.register_uri(:get, "http://develoepr.qiniu.com/", :body => {:abc => 123}.to_json)
30
+ res = Utils.send_request_with 'http://develoepr.qiniu.com/', nil, :method => :get
31
31
  res.should == [200, {"abc" => 123}, {}]
32
32
  end
33
33
 
@@ -35,9 +35,9 @@ module Qiniu
35
35
  context "upstream return http #{code}" do
36
36
  it "should raise RestClient::RequestFailed" do
37
37
  FakeWeb.allow_net_connect = false
38
- FakeWeb.register_uri(:get, "http://docs.qiniutek.com/", :status => code)
38
+ FakeWeb.register_uri(:get, "http://develoepr.qiniu.com/", :status => code)
39
39
  lambda {
40
- res = Utils.send_request_with 'http://docs.qiniutek.com/', nil, :method => :get
40
+ res = Utils.send_request_with 'http://develoepr.qiniu.com/', nil, :method => :get
41
41
  }.should raise_error RestClient::RequestFailed
42
42
  end
43
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qiniu
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.4
4
+ version: 6.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - why404
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-20 00:00:00.000000000 Z
12
+ date: 2014-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake