qiniu 6.6.0 → 6.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +11 -4
- data/CHANGELOG.md +9 -3
- data/README.md +11 -10
- data/examples/copy.rb +25 -0
- data/examples/delete.rb +20 -0
- data/examples/download.rb +11 -0
- data/examples/fops.rb +0 -0
- data/examples/move.rb +26 -0
- data/examples/stat.rb +19 -0
- data/examples/upload.rb +38 -0
- data/examples/upload_callback.rb +41 -0
- data/examples/upload_pfops.rb +47 -0
- data/lib/qiniu/version.rb +1 -1
- data/qiniu.gemspec +1 -1
- data/spec/spec_helper.rb +2 -0
- metadata +15 -7
- data/Gemfile.lock +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a5c78c8aaf5c3fb151d6513187c163c4e1a6c75
|
4
|
+
data.tar.gz: d1c98abc2d8a13cc26ffb35e6620473ef9889069
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1502137ea8b982085cc93c5552d0ca8b69c6103040a5fa82b78b641aec43acc01b05463d8cf63dba5ee18900e9ce3210d08f3185971ccf6cd0f823011145072
|
7
|
+
data.tar.gz: bbf7e1a9618044b23b99a0e4747261c6e64416e5d5aa325f2951f88d19c3ed9026b6c8ab57aeb9cb828f6f5ee5cf57eaa85917d0ed5e2106e2d414af17cbeebc
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 1.
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
- jruby-
|
3
|
+
- 2.1.10
|
4
|
+
- 2.2.4
|
5
|
+
- 2.3.0
|
6
|
+
- jruby-9.0.5.0
|
7
7
|
before_script:
|
8
8
|
- export QINIU_ACCESS_KEY=QWYn5TFQsLLU1pL5MFEmX3s5DmHdUThav9WyOWOm
|
9
9
|
- export QINIU_SECRET_KEY=Bxckh6FA-Fbs9Yt3i3cbKVK22UPBmAOHJcL95pGz
|
10
10
|
gemfile:
|
11
11
|
- Gemfile
|
12
12
|
- rails3/Gemfile
|
13
|
+
deploy:
|
14
|
+
provider: rubygems
|
15
|
+
gemspec: qiniu.gemspec
|
16
|
+
api_key:
|
17
|
+
secure: frhK5TRyrplKjwEktkjx4nGyXBhELae7B/rfDTWUqLrwX4Gmx2XTf0j3VSwKphf2PclW2Phs1o029JFjivgjCB0gYpb4/lgPLxXAjYoUv7cbyZ1SdvIkhJsxilPgkPOr/t6XZ4OB1WU0yLJxDKNyJCh6fHJ47OlMfy7neGPtFKI=
|
18
|
+
on:
|
19
|
+
tags: true
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,20 @@
|
|
1
1
|
## CHANGE LOG
|
2
2
|
|
3
|
-
###
|
3
|
+
### v6.7.0
|
4
|
+
|
5
|
+
- 放弃支持过时的 Ruby 1.9、Ruby 2.0 和 JRuby 1.7。[https://github.com/qiniu/ruby-sdk/pull/149](https://github.com/qiniu/ruby-sdk/pull/149)
|
6
|
+
- 更好地支持 Rails 4。
|
7
|
+
- 确保自动化测试在 CI 上完全通过,为下一步开发做准备。
|
8
|
+
|
9
|
+
### v6.6.0
|
4
10
|
|
5
11
|
- 添加 upload_buffer_with_put_policy() 方法,直接上传一块数据作为文件内容。[https://github.com/qiniu/ruby-sdk/pull/146](https://github.com/qiniu/ruby-sdk/pull/146)
|
6
12
|
|
7
|
-
###
|
13
|
+
### v6.5.2
|
8
14
|
|
9
15
|
- 修正无法触发加载异常类的问题;修正 batch_move 参数未正确打包的问题。[https://github.com/qiniu/ruby-sdk/pull/142](https://github.com/qiniu/ruby-sdk/pull/142)
|
10
16
|
|
11
|
-
###
|
17
|
+
### v6.5.1
|
12
18
|
|
13
19
|
- 为 Qiniu::Auth 添加验证七牛回调请求签名合法性的函数。[https://github.com/qiniu/ruby-sdk/pull/133](https://github.com/qiniu/ruby-sdk/pull/133)
|
14
20
|
|
data/README.md
CHANGED
@@ -2,7 +2,16 @@
|
|
2
2
|
|
3
3
|
## 关于
|
4
4
|
|
5
|
-
此 Ruby SDK
|
5
|
+
此 Ruby SDK 基于 [七牛云存储官方API](http://developer.qiniu.com/docs/v6/index.html) 构建。使用此 SDK 构建您的网络应用程序,能让您以非常便捷地方式将数据安全地存储到七牛云存储上。无论您的网络应用是一个网站程序,还是包括从云端(服务端程序)到终端(手持设备应用)的架构的服务或应用,通过七牛云存储及其 SDK,都能让您应用程序的终端用户高速上传和下载,同时也让您的服务端更加轻盈。
|
6
|
+
|
7
|
+
支持的 Ruby 版本:
|
8
|
+
|
9
|
+
* Ruby 2.1.x
|
10
|
+
* Ruby 2.2.x
|
11
|
+
* Ruby 2.3.x
|
12
|
+
* JRuby 9.x
|
13
|
+
|
14
|
+
如果您的应用程序需要在 Ruby 1.9、2.0 或 JRuby 1.7 上运行,请使用此 Ruby SDK 的 6.6.0 版本。
|
6
15
|
|
7
16
|
## 状态
|
8
17
|
|
@@ -15,7 +24,7 @@
|
|
15
24
|
|
16
25
|
在您 Ruby 应用程序的 `Gemfile` 文件中,添加如下一行代码:
|
17
26
|
|
18
|
-
gem 'qiniu', '
|
27
|
+
gem 'qiniu', '>= 6.7.0'
|
19
28
|
|
20
29
|
然后,在应用程序所在的目录下,可以运行 `bundle` 安装依赖包:
|
21
30
|
|
@@ -25,14 +34,6 @@
|
|
25
34
|
|
26
35
|
$ gem install qiniu
|
27
36
|
|
28
|
-
## Rails 4 项目安装
|
29
|
-
|
30
|
-
在 Rails 4 项目的 `Gemfile` 里添加 `qiniu` 后执行 `bundle` 命令可能会失败,这是因为 Rails 4 项目默认会使用 `mime-types` 3.x 版本。需要使用以下命令将 `mime-types` 降级为满足 Qiniu Ruby SDK 的 2.6.x 版本。
|
31
|
-
|
32
|
-
bundle update mime-types
|
33
|
-
|
34
|
-
由于 `mime-types` 3.0 要求的最低 Ruby 版本是 2.0,而 Qiniu Ruby SDK 支持 Ruby 1.9,因此我们不能通过简单修改对 `mime-types` 的版本依赖来解决此问题。
|
35
|
-
|
36
37
|
## 使用
|
37
38
|
|
38
39
|
参考文档:[七牛云存储 Ruby SDK 使用指南](http://developer.qiniu.com/docs/v6/sdk/ruby-sdk.html)
|
data/examples/copy.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'qiniu'
|
4
|
+
|
5
|
+
Qiniu.establish_connection! :access_key => 'Access_Key',
|
6
|
+
:secret_key => 'Secret_Key'
|
7
|
+
|
8
|
+
#你要测试的空间, 并且这个key在你空间中存在
|
9
|
+
bucket = 'Bucket_Name'
|
10
|
+
key = 'ruby-logo.png'
|
11
|
+
|
12
|
+
#复制到的目标空间名和重命名的key
|
13
|
+
dst_bucket = 'dst_bucket'
|
14
|
+
dst_key = 'dst_key'
|
15
|
+
|
16
|
+
#复制文件
|
17
|
+
code, result, response_headers = Qiniu::Storage.copy(
|
18
|
+
bucket, # 源存储空间
|
19
|
+
key, # 源资源名
|
20
|
+
dst_bucket, # 目标存储空间
|
21
|
+
dst_key # 目标资源名
|
22
|
+
)
|
23
|
+
puts code
|
24
|
+
puts result
|
25
|
+
puts response_headers
|
data/examples/delete.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'qiniu'
|
4
|
+
|
5
|
+
Qiniu.establish_connection! :access_key => 'Access_Key',
|
6
|
+
:secret_key => 'Secret_Key'
|
7
|
+
|
8
|
+
#你要测试的空间, 并且这个key在你空间中存在
|
9
|
+
bucket = 'Bucket_Name'
|
10
|
+
key = 'ruby-logo.png'
|
11
|
+
|
12
|
+
#删除资源
|
13
|
+
code, result, response_headers = Qiniu::Storage.delete(
|
14
|
+
bucket, # 存储空间
|
15
|
+
key # 资源名
|
16
|
+
)
|
17
|
+
|
18
|
+
puts code
|
19
|
+
puts result
|
20
|
+
puts response_headers
|
data/examples/fops.rb
ADDED
File without changes
|
data/examples/move.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'qiniu'
|
4
|
+
|
5
|
+
Qiniu.establish_connection! :access_key => 'Access_Key',
|
6
|
+
:secret_key => 'Secret_Key'
|
7
|
+
|
8
|
+
#你要测试的空间, 并且这个key在你空间中存在
|
9
|
+
bucket = 'Bucket_Name';
|
10
|
+
key = 'ruby-logo.png';
|
11
|
+
|
12
|
+
#移动到的目标空间名和重命名的key
|
13
|
+
dst_bucket = 'dst_bucket'
|
14
|
+
dst_key = 'dst_key'
|
15
|
+
|
16
|
+
|
17
|
+
#移动文件
|
18
|
+
code, result, response_headers = Qiniu::Storage.move(
|
19
|
+
bucket, # 源存储空间
|
20
|
+
key, # 源资源名
|
21
|
+
dst_bucket, # 目标存储空间
|
22
|
+
dst_key # 目标资源名
|
23
|
+
)
|
24
|
+
puts code
|
25
|
+
puts result
|
26
|
+
puts response_headers
|
data/examples/stat.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'qiniu'
|
4
|
+
|
5
|
+
Qiniu.establish_connection! :access_key => 'Access_Key',
|
6
|
+
:secret_key => 'Secret_Key'
|
7
|
+
|
8
|
+
#你要测试的空间, 并且这个key在你空间中存在
|
9
|
+
bucket = 'Bucket_Name';
|
10
|
+
key = 'ruby-logo.png';
|
11
|
+
|
12
|
+
#获取文件信息
|
13
|
+
code, result, response_headers = Qiniu::Storage.stat(
|
14
|
+
bucket, # 存储空间
|
15
|
+
key # 资源名
|
16
|
+
)
|
17
|
+
puts code
|
18
|
+
puts result
|
19
|
+
puts response_headers
|
data/examples/upload.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'qiniu'
|
4
|
+
|
5
|
+
# 构建鉴权对象
|
6
|
+
Qiniu.establish_connection! :access_key => 'Access_Key',
|
7
|
+
:secret_key => 'Secret_Key'
|
8
|
+
|
9
|
+
#要上传的空间
|
10
|
+
bucket = 'Bucket_Name'
|
11
|
+
|
12
|
+
#上传到七牛后保存的文件名
|
13
|
+
key = 'my-ruby-logo.png'
|
14
|
+
|
15
|
+
|
16
|
+
#构建上传策略
|
17
|
+
put_policy = Qiniu::Auth::PutPolicy.new(
|
18
|
+
bucket, # 存储空间
|
19
|
+
key, # 最终资源名,可省略,即缺省为“创建”语义,设置为nil为普通上传
|
20
|
+
3600 #token过期时间,默认为3600s
|
21
|
+
)
|
22
|
+
|
23
|
+
#生成上传 Token
|
24
|
+
uptoken = Qiniu::Auth.generate_uptoken(put_policy)
|
25
|
+
|
26
|
+
#要上传文件的本地路径
|
27
|
+
filePath = './ruby-logo.png'
|
28
|
+
|
29
|
+
#调用upload_with_token_2方法上传
|
30
|
+
code, result, response_headers = Qiniu::Storage.upload_with_token_2(
|
31
|
+
uptoken,
|
32
|
+
filePath,
|
33
|
+
key
|
34
|
+
)
|
35
|
+
|
36
|
+
#打印上传返回的信息
|
37
|
+
puts code
|
38
|
+
puts result
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'qiniu'
|
4
|
+
|
5
|
+
# 构建鉴权对象
|
6
|
+
Qiniu.establish_connection! :access_key => 'Access_Key',
|
7
|
+
:secret_key => 'Secret_Key'
|
8
|
+
|
9
|
+
bucket = 'Bucket_Name'
|
10
|
+
|
11
|
+
key = 'my-ruby-logo.png'
|
12
|
+
|
13
|
+
put_policy = Qiniu::Auth::PutPolicy.new(
|
14
|
+
bucket, # 存储空间
|
15
|
+
key, # 最终资源名,可省略,即缺省为“创建”语义,设置为nil为普通上传
|
16
|
+
3600 #token过期时间,默认为3600s
|
17
|
+
)
|
18
|
+
|
19
|
+
#构建回调策略,这里上传文件到七牛后, 七牛将文件名和文件大小回调给业务服务器.
|
20
|
+
callback_url = 'http://your.domain.com/callback'
|
21
|
+
callback_body = 'filename=$(fname)&filesize=$(fsize)'
|
22
|
+
|
23
|
+
put_policy.callback_url= callback_url
|
24
|
+
put_policy.callback_body= callback_body
|
25
|
+
|
26
|
+
#生成上传 Token
|
27
|
+
uptoken = Qiniu::Auth.generate_uptoken(put_policy)
|
28
|
+
|
29
|
+
#要上传文件的本地路径
|
30
|
+
filePath = './ruby-logo.png'
|
31
|
+
|
32
|
+
#调用upload_with_token_2方法上传
|
33
|
+
code, result, response_headers = Qiniu::Storage.upload_with_token_2(
|
34
|
+
uptoken,
|
35
|
+
filePath,
|
36
|
+
key
|
37
|
+
)
|
38
|
+
|
39
|
+
#打印上传返回的信息
|
40
|
+
puts code
|
41
|
+
puts result
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'qiniu'
|
4
|
+
|
5
|
+
# 构建鉴权对象
|
6
|
+
Qiniu.establish_connection! :access_key => 'Access_Key',
|
7
|
+
:secret_key => 'Secret_Key'
|
8
|
+
|
9
|
+
bucket = 'Bucket_Name'
|
10
|
+
|
11
|
+
key = 'my-ruby-logo.png'
|
12
|
+
|
13
|
+
put_policy = Qiniu::Auth::PutPolicy.new(
|
14
|
+
bucket, # 存储空间
|
15
|
+
key, # 最终资源名,可省略,即缺省为“创建”语义,设置为nil为普通上传
|
16
|
+
3600 #token过期时间,默认为3600s
|
17
|
+
)
|
18
|
+
|
19
|
+
#转码是使用的队列名称。
|
20
|
+
pipeline = 'abc' #设定自己账号下的pipleline
|
21
|
+
|
22
|
+
#要进行转码的转码操作。
|
23
|
+
fops = "avthumb/mp4/s/640x360/vb/1.25m"
|
24
|
+
|
25
|
+
#可以对转码后的文件进行使用saveas参数自定义命名,当然也可以不指定文件会默认命名并保存在当间。
|
26
|
+
saveas_key = Qiniu::Utils.urlsafe_base64_encode(目标Bucket_Name:自定义文件key)
|
27
|
+
fops = fops+'|saveas/'+saveas_key
|
28
|
+
|
29
|
+
put_policy.persistent_ops= fops
|
30
|
+
put_policy.persistent_pipeline= pipeline
|
31
|
+
|
32
|
+
#生成上传 Token
|
33
|
+
uptoken = Qiniu::Auth.generate_uptoken(put_policy)
|
34
|
+
|
35
|
+
#要上传文件的本地路径
|
36
|
+
filePath = './ruby-logo.png'
|
37
|
+
|
38
|
+
#调用upload_with_token_2方法上传
|
39
|
+
code, result, response_headers = Qiniu::Storage.upload_with_token_2(
|
40
|
+
uptoken,
|
41
|
+
filePath,
|
42
|
+
key
|
43
|
+
)
|
44
|
+
|
45
|
+
#打印上传返回的信息
|
46
|
+
puts code
|
47
|
+
puts result
|
data/lib/qiniu/version.rb
CHANGED
data/qiniu.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.add_development_dependency "fakeweb", "~> 1.3"
|
24
24
|
gem.add_runtime_dependency "json", "~> 1.8"
|
25
25
|
gem.add_runtime_dependency "rest-client", "~> 1.8.0"
|
26
|
-
gem.add_runtime_dependency "mime-types", "
|
26
|
+
gem.add_runtime_dependency "mime-types", ">= 2.4.0"
|
27
27
|
gem.add_runtime_dependency "ruby-hmac", "~> 0.4"
|
28
28
|
gem.add_runtime_dependency "jruby-openssl", "~> 0.7" if RUBY_PLATFORM == "java"
|
29
29
|
end
|
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 6.7.0
|
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: 2016-
|
12
|
+
date: 2016-05-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -85,16 +85,16 @@ dependencies:
|
|
85
85
|
name: mime-types
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - '>='
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 2.4.
|
90
|
+
version: 2.4.0
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - '>='
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 2.4.
|
97
|
+
version: 2.4.0
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: ruby-hmac
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,11 +121,19 @@ files:
|
|
121
121
|
- .travis.yml
|
122
122
|
- CHANGELOG.md
|
123
123
|
- Gemfile
|
124
|
-
- Gemfile.lock
|
125
124
|
- LICENSE
|
126
125
|
- README.md
|
127
126
|
- Rakefile
|
128
127
|
- docs/README.md
|
128
|
+
- examples/copy.rb
|
129
|
+
- examples/delete.rb
|
130
|
+
- examples/download.rb
|
131
|
+
- examples/fops.rb
|
132
|
+
- examples/move.rb
|
133
|
+
- examples/stat.rb
|
134
|
+
- examples/upload.rb
|
135
|
+
- examples/upload_callback.rb
|
136
|
+
- examples/upload_pfops.rb
|
129
137
|
- lib/qiniu-rs.rb
|
130
138
|
- lib/qiniu.rb
|
131
139
|
- lib/qiniu/abstract.rb
|
data/Gemfile.lock
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
qiniu (6.5.1)
|
5
|
-
json (~> 1.8)
|
6
|
-
mime-types (~> 1.19)
|
7
|
-
rest-client (~> 1.8.0)
|
8
|
-
ruby-hmac (~> 0.4)
|
9
|
-
|
10
|
-
GEM
|
11
|
-
remote: https://rubygems.org/
|
12
|
-
specs:
|
13
|
-
diff-lcs (1.2.5)
|
14
|
-
fakeweb (1.3.0)
|
15
|
-
json (1.8.2)
|
16
|
-
mime-types (1.25.1)
|
17
|
-
netrc (0.10.3)
|
18
|
-
rake (10.4.2)
|
19
|
-
rest-client (1.8.0)
|
20
|
-
http-cookie (>= 1.0.2, < 2.0)
|
21
|
-
mime-types (>= 1.16, < 3.0)
|
22
|
-
netrc (~> 0.7)
|
23
|
-
rspec (3.2.0)
|
24
|
-
rspec-core (~> 3.2.0)
|
25
|
-
rspec-expectations (~> 3.2.0)
|
26
|
-
rspec-mocks (~> 3.2.0)
|
27
|
-
rspec-core (3.2.2)
|
28
|
-
rspec-support (~> 3.2.0)
|
29
|
-
rspec-expectations (3.2.0)
|
30
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
-
rspec-support (~> 3.2.0)
|
32
|
-
rspec-mocks (3.2.1)
|
33
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
-
rspec-support (~> 3.2.0)
|
35
|
-
rspec-support (3.2.2)
|
36
|
-
ruby-hmac (0.4.0)
|
37
|
-
|
38
|
-
PLATFORMS
|
39
|
-
ruby
|
40
|
-
|
41
|
-
DEPENDENCIES
|
42
|
-
fakeweb (~> 1.3)
|
43
|
-
qiniu!
|
44
|
-
rake (>= 0.9)
|
45
|
-
rspec (>= 2.11)
|