qingstor-sdk 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 121f4fa26d746085c9c07a1217863b907228aaac
4
- data.tar.gz: b41e30469b51ea9d1ce6acd983d9371bfc41a348
3
+ metadata.gz: 085dc72ef0fba628a4b5333907aa8908ccc13d09
4
+ data.tar.gz: 8aefd7a35683cedafacc9d9ac210ad6ff1963d08
5
5
  SHA512:
6
- metadata.gz: 26183f925125c74f9cafdd94786229f4a87ff9689dfcdea1a63a58f26a4ad9a5be7d034b7284e56578a269d70b45c7bca096b2e4747289d2950ee63aec384b57
7
- data.tar.gz: b5c50f4616a145c5637c16eec5aee9f28fe8f0c1a943a195fd41a049235efa26b6a48da0acd4eeeda949707c95e34484c92a1a13f41c3110ed2b211489a6db9b
6
+ metadata.gz: 11d22ac48463e77c861b4a2de66927d6a09ab51c67f9cbd0c2619e392dc0d4b5a751f4c06c0b48b753f898fe6ab440b99f665131db2b6b7ae181c26fc6ee25c7
7
+ data.tar.gz: e987a50acafb8b714a283abe3c3bcd4e74891a34a030ccc2dead7b00424587510cf6ca7ab7f6e575e8240572a5fc2c3ce45706be982114ec03aac9c2d3af9079
data/README.md CHANGED
@@ -167,11 +167,23 @@ log_level: 'warn'
167
167
  ## Change Log
168
168
  All notable changes to QingStor SDK for Ruby will be documented here.
169
169
 
170
+ ### [v2.1.0] - 2016-12-24
171
+
172
+ #### Changed
173
+ - Fix signer bug.
174
+ - Add more parameters to sign.
175
+
176
+ #### Added
177
+ - Add request parameters for GET Object.
178
+ - Add IP address conditions for bucket policy.
179
+
170
180
  ### [v2.0.1] - 2016-12-16
181
+
171
182
  #### Changed
172
183
  - Improve the implementation of deleting multiple objects.
173
184
 
174
185
  ### v2.0.0 - 2016-12-14
186
+
175
187
  #### Added
176
188
  - QingStor SDK for the Ruby programming language.
177
189
 
@@ -193,4 +205,5 @@ All notable changes to QingStor SDK for Ruby will be documented here.
193
205
 
194
206
  The Apache License (Version 2.0, January 2004).
195
207
 
208
+ [v2.1.0]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.0.1...v2.1.0
196
209
  [v2.0.1]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.0.0...v2.0.1
@@ -14,6 +14,7 @@
14
14
  # | limitations under the License.
15
15
  # +-------------------------------------------------------------------------
16
16
 
17
+ require 'cgi'
17
18
  require 'base64'
18
19
  require 'digest'
19
20
 
@@ -29,6 +30,7 @@ module QingStor
29
30
  input[:request_uri] = request_uri input
30
31
  input[:request_body] = request_body input
31
32
  input[:request_headers] = request_headers input
33
+ input[:request_params] = request_params input
32
34
 
33
35
  display = {}
34
36
  input.each { |k, v| display[k] = v unless k.to_s == 'request_body' }
@@ -100,6 +102,16 @@ module QingStor
100
102
  input[:request_headers]
101
103
  end
102
104
 
105
+ def self.request_params(input)
106
+ unless input[:request_params].nil?
107
+ input[:request_params].map do |k, v|
108
+ input[:request_params][k] = CGI.escape v.to_s
109
+ input[:request_params][k].gsub! '+', '%20'
110
+ end
111
+ end
112
+ input[:request_params]
113
+ end
114
+
103
115
  def self.decorate_input(input)
104
116
  input.deep_symbolize_keys!
105
117
  input[:id] = (Random.new.rand * 1_000_000).to_int
@@ -63,7 +63,7 @@ module QingStor
63
63
  def build
64
64
  params = input[:request_params].map { |k, v| "#{k}=#{v}" }
65
65
  query_string = !params.empty? ? "?#{params.join '&'}" : ''
66
- self.request_url = "#{input[:request_endpoint]}#{Signer.escape input[:request_uri]}#{query_string}"
66
+ self.request_url = "#{input[:request_endpoint]}#{input[:request_uri]}#{query_string}"
67
67
 
68
68
  request = new_http_request input[:request_method], request_url
69
69
  request.body = input[:request_body]
@@ -87,29 +87,24 @@ module QingStor
87
87
  end
88
88
 
89
89
  def self.canonicalized_resource(input)
90
- path = escape input[:request_uri]
90
+ path = input[:request_uri]
91
91
 
92
92
  params = input[:request_params].keys.sort.map { |k|
93
93
  if sub_resource? k.to_s
94
94
  v = input[:request_params][k].to_s.strip
95
- !v.nil? && v != '' ? "#{k}=#{escape v}" : k
95
+ !v.nil? && v != '' ? "#{k}=#{CGI.unescape v}" : k
96
96
  end
97
97
  }.compact.join '&'
98
98
  params = path.include?('?') ? "&#{params}" : "?#{params}" if params != ''
99
99
  "#{path}#{params}"
100
100
  end
101
101
 
102
- def self.escape(original)
103
- result = CGI.escape(original)
104
- result.gsub! '%3F', '?'
105
- result.gsub! '%2F', '/'
106
- result.gsub! '+', '%20'
107
- result.gsub! '%2B', '+'
108
- result
109
- end
110
-
111
102
  def self.sub_resource?(key)
112
- %w(acl cors delete mirror part_number policy stats upload_id uploads).include? key
103
+ %w(
104
+ acl cors delete mirror part_number policy stats upload_id uploads
105
+ response-expires response-cache-control response-content-type
106
+ response-content-language response-content-encoding response-content-disposition
107
+ ).include? key
113
108
  end
114
109
  end
115
110
  end
@@ -767,10 +767,18 @@ module QingStor
767
767
 
768
768
  unless x['condition'].nil?
769
769
 
770
+ unless x['condition']['ip_address'].nil?
771
+
772
+ end
773
+
770
774
  unless x['condition']['is_null'].nil?
771
775
 
772
776
  end
773
777
 
778
+ unless x['condition']['not_ip_address'].nil?
779
+
780
+ end
781
+
774
782
  unless x['condition']['string_like'].nil?
775
783
 
776
784
  end
@@ -170,7 +170,12 @@ module QingStor
170
170
 
171
171
  # get_object: Retrieve the object.
172
172
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/object/get.html
173
- def get_object(object_key, if_match: '',
173
+ def get_object(object_key, response_cache_control: '',
174
+ response_content_disposition: '',
175
+ response_content_encoding: '',
176
+ response_content_language: '',
177
+ response_content_type: '',
178
+ response_expires: '', if_match: '',
174
179
  if_modified_since: '',
175
180
  if_none_match: '',
176
181
  if_unmodified_since: '',
@@ -178,18 +183,28 @@ module QingStor
178
183
  x_qs_encryption_customer_algorithm: '',
179
184
  x_qs_encryption_customer_key: '',
180
185
  x_qs_encryption_customer_key_md5: '')
181
- request = get_object_request object_key, if_match: if_match,
182
- if_modified_since: if_modified_since,
183
- if_none_match: if_none_match,
184
- if_unmodified_since: if_unmodified_since,
185
- range: range,
186
- x_qs_encryption_customer_algorithm: x_qs_encryption_customer_algorithm,
187
- x_qs_encryption_customer_key: x_qs_encryption_customer_key,
188
- x_qs_encryption_customer_key_md5: x_qs_encryption_customer_key_md5
186
+ request = get_object_request object_key, response_cache_control: response_cache_control,
187
+ response_content_disposition: response_content_disposition,
188
+ response_content_encoding: response_content_encoding,
189
+ response_content_language: response_content_language,
190
+ response_content_type: response_content_type,
191
+ response_expires: response_expires, if_match: if_match,
192
+ if_modified_since: if_modified_since,
193
+ if_none_match: if_none_match,
194
+ if_unmodified_since: if_unmodified_since,
195
+ range: range,
196
+ x_qs_encryption_customer_algorithm: x_qs_encryption_customer_algorithm,
197
+ x_qs_encryption_customer_key: x_qs_encryption_customer_key,
198
+ x_qs_encryption_customer_key_md5: x_qs_encryption_customer_key_md5
189
199
  request.send
190
200
  end
191
201
 
192
- def get_object_request(object_key, if_match: '',
202
+ def get_object_request(object_key, response_cache_control: '',
203
+ response_content_disposition: '',
204
+ response_content_encoding: '',
205
+ response_content_language: '',
206
+ response_content_type: '',
207
+ response_expires: '', if_match: '',
193
208
  if_modified_since: '',
194
209
  if_none_match: '',
195
210
  if_unmodified_since: '',
@@ -205,6 +220,12 @@ module QingStor
205
220
  request_method: 'GET',
206
221
  request_uri: '/<bucket-name>/<object-key>',
207
222
  request_params: {
223
+ 'response-cache-control' => response_cache_control,
224
+ 'response-content-disposition' => response_content_disposition,
225
+ 'response-content-encoding' => response_content_encoding,
226
+ 'response-content-language' => response_content_language,
227
+ 'response-content-type' => response_content_type,
228
+ 'response-expires' => response_expires,
208
229
  },
209
230
  request_headers: {
210
231
  'If-Match' => if_match,
@@ -16,6 +16,6 @@
16
16
 
17
17
  module QingStor
18
18
  module SDK
19
- VERSION = '2.0.1'.freeze
19
+ VERSION = '2.1.0'.freeze
20
20
  end
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qingstor-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yunify SDK Group
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-16 00:00:00.000000000 Z
11
+ date: 2016-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport