qiniu-rs 3.4.1 → 3.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +3 -3
- data/README.md +1 -1
- data/docs/README.md +14 -11
- data/lib/qiniu/rs.rb +1 -0
- data/lib/qiniu/rs/version.rb +1 -1
- data/lib/qiniu/tokens/upload_token.rb +3 -1
- data/spec/qiniu/rs/image_spec.rb +7 -1
- data/spec/spec_helper.rb +1 -2
- metadata +5 -5
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## CHANGE LOG
|
2
2
|
|
3
|
+
### v3.4.2
|
4
|
+
|
5
|
+
- `Qiniu::RS.generate_upload_token()` 方法新增 `:return_body` 选项。
|
6
|
+
|
7
|
+
该选项(`:return_body`)可设置文件上传成功后,执行七牛云存储规定的回调API,并以 JSON 响应格式返回其执行结果。参考 [uploadToken 之 returnBody 说明](http://docs.qiniutek.com/v3/api/io/#uploadToken-returnBody)。
|
8
|
+
|
3
9
|
### v3.4.1
|
4
10
|
|
5
11
|
增加为上传文件进行预转的选项,参见 [uploadToken 之 asyncOps 说明](http://docs.qiniutek.com/v3/api/io/#uploadToken-asyncOps)
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
qiniu-rs (3.4.
|
4
|
+
qiniu-rs (3.4.2)
|
5
5
|
json (~> 1.7)
|
6
6
|
mime-types (~> 1.19)
|
7
7
|
rest-client (~> 1.6)
|
@@ -13,7 +13,7 @@ GEM
|
|
13
13
|
diff-lcs (1.1.3)
|
14
14
|
fakeweb (1.3.0)
|
15
15
|
json (1.7.6)
|
16
|
-
mime-types (1.
|
16
|
+
mime-types (1.20.1)
|
17
17
|
rake (10.0.3)
|
18
18
|
rest-client (1.6.7)
|
19
19
|
mime-types (>= 1.16)
|
@@ -24,7 +24,7 @@ GEM
|
|
24
24
|
rspec-core (2.12.2)
|
25
25
|
rspec-expectations (2.12.1)
|
26
26
|
diff-lcs (~> 1.1.3)
|
27
|
-
rspec-mocks (2.12.
|
27
|
+
rspec-mocks (2.12.2)
|
28
28
|
ruby-hmac (0.4.0)
|
29
29
|
|
30
30
|
PLATFORMS
|
data/README.md
CHANGED
data/docs/README.md
CHANGED
@@ -126,7 +126,8 @@ title: Ruby SDK 使用指南 | 七牛云存储
|
|
126
126
|
:callback_body_type => callback_body_type,
|
127
127
|
:customer => end_user_id,
|
128
128
|
:escape => allow_upload_callback_api,
|
129
|
-
:async_options => async_callback_api_commands
|
129
|
+
:async_options => async_callback_api_commands,
|
130
|
+
:return_body => custom_response_body
|
130
131
|
|
131
132
|
**参数**
|
132
133
|
|
@@ -159,7 +160,11 @@ title: Ruby SDK 使用指南 | 七牛云存储
|
|
159
160
|
`foo=bar&w=$(imageInfo.width)&h=$(imageInfo.height)&exif=$(exif)`
|
160
161
|
|
161
162
|
:async_options
|
162
|
-
: 可选,字符串类型(String
|
163
|
+
: 可选,字符串类型(String),用于设置文件上传成功后,执行指定的预转指令。参考 [uploadToken 之 asyncOps 说明](http://docs.qiniutek.com/v3/api/io/#uploadToken-asyncOps)
|
164
|
+
|
165
|
+
:return_body
|
166
|
+
: 可选,字符串类型(String),用于设置文件上传成功后,执行七牛云存储规定的回调API,并以 JSON 响应格式返回其执行结果。参考 [uploadToken 之 returnBody 说明](/v3/api/io/#uploadToken-returnBody)。
|
167
|
+
|
163
168
|
|
164
169
|
**返回值**
|
165
170
|
|
@@ -320,10 +325,10 @@ title: Ruby SDK 使用指南 | 七牛云存储
|
|
320
325
|
**参数**
|
321
326
|
|
322
327
|
expires_in
|
323
|
-
: 可选,数字类型,用于设置上传 URL 的有效期,单位:秒,缺省为 3600 秒,即 1
|
328
|
+
: 可选,数字类型,用于设置上传 URL 的有效期,单位:秒,缺省为 3600 秒,即 1 小时后该下载授权凭证(downloadToken)不再有效。
|
324
329
|
|
325
330
|
pattern
|
326
|
-
:
|
331
|
+
: 必须,字符串类型,用于设置可匹配的下载链接。参考:[downloadToken pattern 详解](/v3/api/io/#download-token-pattern)
|
327
332
|
|
328
333
|
|
329
334
|
<a name="other-download-features"></a>
|
@@ -753,11 +758,9 @@ mogrify_options
|
|
753
758
|
thumbnail = Qiniu::RS.get(target_bucket, target_key)
|
754
759
|
puts thumbnail["url"]
|
755
760
|
|
756
|
-
# 您可以选择将存放缩略图的 bucket 公开,这样就可以直接以外链的形式访问到缩略图,而不用走API获取下载URL
|
757
|
-
result = Qiniu::RS.publish("pic.example.com", target_bucket)
|
761
|
+
# 您可以选择将存放缩略图的 bucket 公开,这样就可以直接以外链的形式访问到缩略图,而不用走API获取下载URL,就可以直接以如下方式访问缩略图:
|
758
762
|
|
759
|
-
#
|
760
|
-
# [GET] http://pic.example.com/<target_key>
|
763
|
+
# [GET] http://<bucket>.qiniudn.com/<target_key>
|
761
764
|
end
|
762
765
|
|
763
766
|
|
@@ -765,10 +768,10 @@ mogrify_options
|
|
765
768
|
|
766
769
|
## 贡献代码
|
767
770
|
|
768
|
-
七牛云存储 Ruby SDK
|
771
|
+
七牛云存储 Ruby SDK 源码地址:<https://github.com/qiniu/ruby-sdk>
|
769
772
|
|
770
|
-
1. 登录
|
771
|
-
2. Fork
|
773
|
+
1. 登录 <https://github.com>
|
774
|
+
2. Fork <https://github.com/qiniu/ruby-sdk>
|
772
775
|
3. 创建您的特性分支 (`git checkout -b my-new-feature`)
|
773
776
|
4. 提交您的改动 (`git commit -am 'Added some feature'`)
|
774
777
|
5. 将您的改动记录提交到远程 `git` 仓库 (`git push origin my-new-feature`)
|
data/lib/qiniu/rs.rb
CHANGED
data/lib/qiniu/rs/version.rb
CHANGED
@@ -10,7 +10,7 @@ module Qiniu
|
|
10
10
|
|
11
11
|
include Utils
|
12
12
|
|
13
|
-
attr_accessor :scope, :expires_in, :callback_url, :callback_body_type, :customer, :escape, :async_options
|
13
|
+
attr_accessor :scope, :expires_in, :callback_url, :callback_body_type, :customer, :escape, :async_options, :return_body
|
14
14
|
|
15
15
|
def initialize(opts = {})
|
16
16
|
@scope = opts[:scope]
|
@@ -20,6 +20,7 @@ module Qiniu
|
|
20
20
|
@customer = opts[:customer]
|
21
21
|
@escape = opts[:escape]
|
22
22
|
@async_options = opts[:async_options]
|
23
|
+
@return_body = opts[:return_body]
|
23
24
|
end
|
24
25
|
|
25
26
|
def generate_signature
|
@@ -29,6 +30,7 @@ module Qiniu
|
|
29
30
|
params[:customer] = @customer if !@customer.nil? && !@customer.empty?
|
30
31
|
params[:escape] = 1 if @escape == 1 || @escape == true
|
31
32
|
params[:asyncOps] = @async_options if !@async_options.nil? && !@async_options.empty?
|
33
|
+
params[:returnBody] = @return_body if !@return_body.nil? && !@return_body.empty?
|
32
34
|
Utils.urlsafe_base64_encode(params.to_json)
|
33
35
|
end
|
34
36
|
|
data/spec/qiniu/rs/image_spec.rb
CHANGED
@@ -24,12 +24,18 @@ module Qiniu
|
|
24
24
|
:scope => @bucket,
|
25
25
|
:expires_in => 3600,
|
26
26
|
:customer => "why404@gmail.com",
|
27
|
-
:async_options => "imageView/1/w/120/h/120"
|
27
|
+
:async_options => "imageView/1/w/120/h/120",
|
28
|
+
:return_body => '{"size":$(fsize), "hash":$(etag), "width":$(imageInfo.width), "height":$(imageInfo.height)}'
|
28
29
|
}
|
29
30
|
uptoken = Qiniu::RS.generate_upload_token(upopts)
|
30
31
|
data = Qiniu::RS.upload_file :uptoken => uptoken, :file => local_file, :bucket => @bucket, :key => @key
|
31
32
|
puts data.inspect
|
32
33
|
|
34
|
+
data["size"].should_not be_zero
|
35
|
+
data["hash"].should_not be_empty
|
36
|
+
data["width"].should_not be_zero
|
37
|
+
data["height"].should_not be_zero
|
38
|
+
|
33
39
|
result = Qiniu::RS.get(@bucket, @key)
|
34
40
|
result["url"].should_not be_empty
|
35
41
|
puts result.inspect
|
data/spec/spec_helper.rb
CHANGED
@@ -6,7 +6,6 @@ require 'rspec'
|
|
6
6
|
|
7
7
|
RSpec.configure do |config|
|
8
8
|
config.before :all do
|
9
|
-
Qiniu::RS.establish_connection! :access_key => "
|
10
|
-
:secret_key => "6QTOr2Jg1gcZEWDQXKOGZh5PziC2MCV5KsntT70j"
|
9
|
+
Qiniu::RS.establish_connection! :access_key => ENV["QINIU_ACCESS_KEY"], :secret_key => ENV["QINIU_SECRET_KEY"]
|
11
10
|
end
|
12
11
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qiniu-rs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -188,7 +188,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
188
|
version: '0'
|
189
189
|
segments:
|
190
190
|
- 0
|
191
|
-
hash: -
|
191
|
+
hash: -4169114018615426400
|
192
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
193
|
none: false
|
194
194
|
requirements:
|
@@ -197,10 +197,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
197
|
version: '0'
|
198
198
|
segments:
|
199
199
|
- 0
|
200
|
-
hash: -
|
200
|
+
hash: -4169114018615426400
|
201
201
|
requirements: []
|
202
202
|
rubyforge_project:
|
203
|
-
rubygems_version: 1.8.
|
203
|
+
rubygems_version: 1.8.25
|
204
204
|
signing_key:
|
205
205
|
specification_version: 3
|
206
206
|
summary: Qiniu Resource (Cloud) Storage SDK for Ruby
|