qiniu 6.3.2 → 6.4.0
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/qiniu/config.rb +2 -1
- data/lib/qiniu/management.rb +60 -1
- data/lib/qiniu/upload.rb +13 -4
- data/lib/qiniu/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 904dd3defbe758fc4ee3e823983e417179a91ee8
|
4
|
+
data.tar.gz: 5bb0b1ce13cca8bd025424d01a9b13f162d2c391
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a26f6c5a2ed13eb534e0d43bb0a0ce90be118564143f235b3f9d5c7b55659dba211a596e59a76d85fa07651b2f2cd7eaba9c554fe8fdd21b19e2b1f43ff2eaf
|
7
|
+
data.tar.gz: 2e22236452c242c657b2a726eda091fc9a564210b9f52ea2111470b2422bc2a223e561c3548993c430fde0d24791cba6377bf625b1515513ebd309f25a4657dd
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
## CHANGE LOG
|
2
2
|
|
3
|
+
### v6.4.0
|
4
|
+
|
5
|
+
- 为 put_with_put_policy() 添加 opts 参数,允许使用 :content_type 键指定上传文件的 mime type。 [https://github.com/qiniu/ruby-sdk/pull/111](https://github.com/qiniu/ruby-sdk/pull/111)
|
6
|
+
|
3
7
|
### v6.3.2
|
4
8
|
|
5
9
|
- 调整上传host。 [https://github.com/qiniu/ruby-sdk/pull/103](https://github.com/qiniu/ruby-sdk/pull/103)
|
data/Gemfile.lock
CHANGED
data/lib/qiniu/config.rb
CHANGED
@@ -20,7 +20,8 @@ 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
|
-
:
|
23
|
+
:rsf_host => "http://rsf.qbox.me",
|
24
|
+
:up_host => "http://up.qiniu.com",
|
24
25
|
:pub_host => "http://pu.qbox.me:10200",
|
25
26
|
:eu_host => "http://eu.qbox.me",
|
26
27
|
:access_key => "",
|
data/lib/qiniu/management.rb
CHANGED
@@ -1,10 +1,48 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
# vim: sw=2 ts=2
|
3
3
|
|
4
|
+
require 'qiniu/adt'
|
4
5
|
require 'qiniu/http'
|
5
6
|
|
6
7
|
module Qiniu
|
7
8
|
module Storage
|
9
|
+
class ListPolicy
|
10
|
+
include ADT::Policy
|
11
|
+
|
12
|
+
private
|
13
|
+
def initialize(bucket,
|
14
|
+
limit = 1000,
|
15
|
+
prefix = '',
|
16
|
+
delimiter = '')
|
17
|
+
@bucket = bucket
|
18
|
+
@limit = limit
|
19
|
+
@prefix = prefix
|
20
|
+
@delimiter = delimiter
|
21
|
+
end # initialize
|
22
|
+
|
23
|
+
public
|
24
|
+
PARAMS = {
|
25
|
+
# 字符串类型参数
|
26
|
+
:bucket => "bucket",
|
27
|
+
:prefix => "prefix",
|
28
|
+
:delimiter => "delimiter",
|
29
|
+
:marker => "marker",
|
30
|
+
|
31
|
+
# 数值类型参数
|
32
|
+
:limit => "limit"
|
33
|
+
} # PARAMS
|
34
|
+
|
35
|
+
PARAMS.each_pair do |key, fld|
|
36
|
+
attr_accessor key
|
37
|
+
end
|
38
|
+
|
39
|
+
def params
|
40
|
+
return PARAMS
|
41
|
+
end # params
|
42
|
+
|
43
|
+
alias :to_s :to_query_string
|
44
|
+
end # class ListPolicy
|
45
|
+
|
8
46
|
class << self
|
9
47
|
include Utils
|
10
48
|
|
@@ -86,6 +124,26 @@ module Qiniu
|
|
86
124
|
save_as(bucket, key, source_image_url, mogrify_params_string)
|
87
125
|
end # image_mogrify_save_as
|
88
126
|
|
127
|
+
def list(list_policy)
|
128
|
+
url = Config.settings[:rsf_host] + '/list?' + list_policy.to_query_string()
|
129
|
+
|
130
|
+
resp_code, resp_body, resp_headers = HTTP.management_post(url)
|
131
|
+
if resp_code == 0 || resp_code > 299 then
|
132
|
+
has_more = false
|
133
|
+
return resp_code, resp_body, resp_headers, has_more, list_policy
|
134
|
+
end
|
135
|
+
|
136
|
+
has_more = (resp_body['marker'].is_a?(String) && resp_body['marker'] != '')
|
137
|
+
if has_more then
|
138
|
+
new_list_policy = list_policy.clone()
|
139
|
+
new_list_policy.marker = resp_body['marker']
|
140
|
+
else
|
141
|
+
new_list_policy = list_policy
|
142
|
+
end
|
143
|
+
|
144
|
+
return resp_code, resp_body, resp_headers, has_more, new_list_policy
|
145
|
+
end # list
|
146
|
+
|
89
147
|
private
|
90
148
|
|
91
149
|
def _generate_cp_or_mv_opstr(command, source_bucket, source_key, target_bucket, target_key)
|
@@ -102,6 +160,7 @@ module Qiniu
|
|
102
160
|
url = Config.settings[:rs_host] + "/batch"
|
103
161
|
return HTTP.management_post(url, execs.join("&"))
|
104
162
|
end # _batch_cp_or_mv
|
105
|
-
|
163
|
+
|
164
|
+
end # class << self
|
106
165
|
end # module Storage
|
107
166
|
end # module Qiniu
|
data/lib/qiniu/upload.rb
CHANGED
@@ -47,15 +47,23 @@ module Qiniu
|
|
47
47
|
def upload_with_token_2(uptoken,
|
48
48
|
local_file,
|
49
49
|
key = nil,
|
50
|
-
x_vars = nil
|
50
|
+
x_vars = nil,
|
51
|
+
opts = {})
|
51
52
|
### 构造URL
|
52
53
|
url = Config.settings[:up_host]
|
53
54
|
url[/\/*$/] = ''
|
54
55
|
url += '/'
|
55
56
|
|
56
57
|
### 构造HTTP Body
|
58
|
+
file = File.new(local_file, 'rb')
|
59
|
+
if not opts[:content_type].nil?
|
60
|
+
file.define_singleton_method("content_type") do
|
61
|
+
opts[:content_type]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
57
65
|
post_data = {
|
58
|
-
:file =>
|
66
|
+
:file => file,
|
59
67
|
:multipart => true,
|
60
68
|
}
|
61
69
|
if not uptoken.nil?
|
@@ -84,13 +92,14 @@ module Qiniu
|
|
84
92
|
def upload_with_put_policy(put_policy,
|
85
93
|
local_file,
|
86
94
|
key = nil,
|
87
|
-
x_vars = nil
|
95
|
+
x_vars = nil,
|
96
|
+
opts = {})
|
88
97
|
uptoken = Auth.generate_uptoken(put_policy)
|
89
98
|
if key.nil? then
|
90
99
|
key = put_policy.key
|
91
100
|
end
|
92
101
|
|
93
|
-
return upload_with_token_2(uptoken, local_file, key, x_vars)
|
102
|
+
return upload_with_token_2(uptoken, local_file, key, x_vars, opts)
|
94
103
|
end # upload_with_put_policy
|
95
104
|
|
96
105
|
private
|
data/lib/qiniu/version.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.4.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: 2014-
|
12
|
+
date: 2014-11-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|