qiniu-rs 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/lib/qiniu/rs/auth.rb +4 -4
- data/lib/qiniu/rs/io.rb +2 -3
- data/lib/qiniu/rs/utils.rb +2 -37
- data/lib/qiniu/rs/version.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
qiniu-rs (2.3.
|
4
|
+
qiniu-rs (2.3.1)
|
5
5
|
json (~> 1.7.3)
|
6
6
|
mime-types (~> 1.19)
|
7
7
|
rest-client (~> 1.6.7)
|
@@ -12,7 +12,7 @@ GEM
|
|
12
12
|
specs:
|
13
13
|
diff-lcs (1.1.3)
|
14
14
|
fakeweb (1.3.0)
|
15
|
-
json (1.7.
|
15
|
+
json (1.7.4)
|
16
16
|
mime-types (1.19)
|
17
17
|
rake (0.9.2.2)
|
18
18
|
rest-client (1.6.7)
|
data/lib/qiniu/rs/auth.rb
CHANGED
@@ -58,17 +58,17 @@ module Qiniu
|
|
58
58
|
[code, data]
|
59
59
|
end
|
60
60
|
|
61
|
-
def call_with_signature(url, data, retry_times = 0)
|
62
|
-
code, data = http_request url, data, {:qbox_signature_token => generate_qbox_signature(url, data)}
|
61
|
+
def call_with_signature(url, data, retry_times = 0, options = {})
|
62
|
+
code, data = http_request url, data, options.merge!({:qbox_signature_token => generate_qbox_signature(url, data)})
|
63
63
|
[code, data]
|
64
64
|
end
|
65
65
|
|
66
|
-
def request(url, data = nil)
|
66
|
+
def request(url, data = nil, options = {})
|
67
67
|
begin
|
68
68
|
if Config.settings[:access_key].empty? || Config.settings[:secret_key].empty?
|
69
69
|
code, data = Auth.call_with_logged_in(url, data)
|
70
70
|
else
|
71
|
-
code, data = Auth.call_with_signature(url, data)
|
71
|
+
code, data = Auth.call_with_signature(url, data, options)
|
72
72
|
end
|
73
73
|
rescue [MissingAccessToken, MissingRefreshToken, MissingUsernameOrPassword] => e
|
74
74
|
Log.logger.error e
|
data/lib/qiniu/rs/io.rb
CHANGED
@@ -30,9 +30,8 @@ module Qiniu
|
|
30
30
|
def put_file(local_file, bucket, key = nil, mime_type = nil, custom_meta = nil, enable_crc32_check = false)
|
31
31
|
action_params = _generate_action_params(local_file, bucket, key, mime_type, custom_meta, enable_crc32_check)
|
32
32
|
url = Config.settings[:io_host] + action_params
|
33
|
-
|
34
|
-
|
35
|
-
Utils.send_multipart_request url, post_data, options
|
33
|
+
options = {:content_type => 'application/octet-stream'}
|
34
|
+
Auth.request url, ::IO.read(local_file), options
|
36
35
|
end
|
37
36
|
|
38
37
|
private
|
data/lib/qiniu/rs/utils.rb
CHANGED
@@ -91,49 +91,14 @@ module Qiniu
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
def send_multipart_request(url, post_data, options = {})
|
95
|
-
code, data = 0, {}
|
96
|
-
begin
|
97
|
-
header_options = {
|
98
|
-
:accept => :json,
|
99
|
-
:user_agent => Config.settings[:user_agent]
|
100
|
-
}
|
101
|
-
auth_token = nil
|
102
|
-
if !options[:qbox_signature_token].nil? && !options[:qbox_signature_token].empty?
|
103
|
-
auth_token = 'QBox ' + options[:qbox_signature_token]
|
104
|
-
#elsif !options[:upload_signature_token].nil? && !options[:upload_signature_token].empty?
|
105
|
-
#auth_token = 'UpToken ' + options[:upload_signature_token]
|
106
|
-
elsif options[:access_token]
|
107
|
-
auth_token = 'Bearer ' + options[:access_token]
|
108
|
-
end
|
109
|
-
header_options.merge!('Authorization' => auth_token) unless auth_token.nil?
|
110
|
-
response = RestClient.post url, post_data, header_options
|
111
|
-
body = response.respond_to?(:body) ? response.body : ""
|
112
|
-
data = safe_json_parse(body) unless body.empty?
|
113
|
-
code = response.code.to_i if response.respond_to?(:code)
|
114
|
-
rescue Errno::ECONNRESET => err
|
115
|
-
Log.logger.error err
|
116
|
-
rescue => e
|
117
|
-
Log.logger.warn "#{e.message} => Utils.http_request('#{url}')"
|
118
|
-
res = e.response
|
119
|
-
if e.respond_to? :response
|
120
|
-
res = e.response
|
121
|
-
code = res.code.to_i if res.respond_to? :code
|
122
|
-
body = res.respond_to?(:body) ? res.body : ""
|
123
|
-
data = safe_json_parse(body) unless body.empty?
|
124
|
-
end
|
125
|
-
end
|
126
|
-
[code, data]
|
127
|
-
end
|
128
|
-
|
129
94
|
def upload_multipart_data(url, filepath, action_string, callback_query_string = '')
|
130
95
|
post_data = {
|
131
|
-
:file => File.new(filepath, 'rb'),
|
132
96
|
:params => callback_query_string,
|
133
97
|
:action => action_string,
|
98
|
+
:file => File.new(filepath, 'rb'),
|
134
99
|
:multipart => true
|
135
100
|
}
|
136
|
-
|
101
|
+
http_request url, post_data
|
137
102
|
end
|
138
103
|
|
139
104
|
def generate_query_string(params)
|
data/lib/qiniu/rs/version.rb
CHANGED
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: 2.3.
|
4
|
+
version: 2.3.1
|
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: 2012-07-
|
12
|
+
date: 2012-07-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -177,7 +177,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
177
|
version: '0'
|
178
178
|
segments:
|
179
179
|
- 0
|
180
|
-
hash:
|
180
|
+
hash: 1949890581175150745
|
181
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
182
|
none: false
|
183
183
|
requirements:
|
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
186
|
version: '0'
|
187
187
|
segments:
|
188
188
|
- 0
|
189
|
-
hash:
|
189
|
+
hash: 1949890581175150745
|
190
190
|
requirements: []
|
191
191
|
rubyforge_project:
|
192
192
|
rubygems_version: 1.8.24
|