aliyun-oss-sdk 0.1.7 → 0.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0001949a848455a73f2af7665744b7ec2582cfae
4
- data.tar.gz: ec117f792a2ec628b3f42aa8b58815d2756fcd54
3
+ metadata.gz: bbf195d34ce4df49ea7a519ff4d05f2c53844a4a
4
+ data.tar.gz: 0acc746359cfb2ce02a6eb005a61f10f41acbd9d
5
5
  SHA512:
6
- metadata.gz: 041d6e77f4becdf642768b07516252f44dfcb4c1857c3d8b602ec5e291a8f10e5b5efb56147b2f403885c88fa0ae9d2ace2b4d12cd6f53f0203e1683ab411d82
7
- data.tar.gz: 7a6f40dec1bc333cbc16b208eb7536647196c51cd64ba8dc7f726b407ef390918e7383e753dabb8aa0354781576a619428b3194e297c6c194b4e9e3dcadb56c5
6
+ metadata.gz: f5faaf0e6ac940d44ddd5a2367d54ffdfdc7d8008badf749159fb83a15092f003fd8c7b11017736823fa2d112ac294ec51ecc249f413abc0807ca516fba14fb2
7
+ data.tar.gz: fe02419091a96c091998b603d0cc9d08e28639d3f4e9c28c1a03e86f865d7702782deee8d1c7457dedd64239153a1004c4b0bb3e08908729ca96f755d6b6239d
@@ -1,3 +1,8 @@
1
+ 0.1.8
2
+ -----
3
+
4
+ - Escape special charaters in object name;
5
+
1
6
  0.1.7
2
7
  -----
3
8
 
@@ -40,7 +40,6 @@ module Aliyun
40
40
  #
41
41
  # @return [Response]
42
42
  def bucket_create_object(key, file, headers = {})
43
- Utils.clean_object_name!(key)
44
43
  Utils.stringify_keys!(headers)
45
44
  http.put("/#{key}", headers: headers, body: Utils.to_data(file), bucket: bucket, key: key)
46
45
  end
@@ -68,7 +67,6 @@ module Aliyun
68
67
  fail('source_bucket must be not empty!') if source_bucket.nil? || source_bucket.empty?
69
68
  fail('source_key must be not empty!') if source_key.nil? || source_key.empty?
70
69
 
71
- Utils.clean_object_name!(key)
72
70
  Utils.stringify_keys!(headers)
73
71
  headers.merge!('x-oss-copy-source' => "/#{source_bucket}/#{source_key}")
74
72
 
@@ -88,7 +86,6 @@ module Aliyun
88
86
  #
89
87
  # @return [Response]
90
88
  def bucket_append_object(key, file, position = 0, headers = {})
91
- Utils.clean_object_name!(key)
92
89
  Utils.stringify_keys!(headers)
93
90
 
94
91
  query = { 'append' => true, 'position' => position }
@@ -118,7 +115,6 @@ module Aliyun
118
115
  #
119
116
  # @return [Response]
120
117
  def bucket_get_object(key, query = {}, headers = {})
121
- Utils.clean_object_name!(key)
122
118
  Utils.stringify_keys!(query)
123
119
  Utils.stringify_keys!(headers)
124
120
 
@@ -134,7 +130,6 @@ module Aliyun
134
130
  def bucket_get_object_share_link(key, expired_in_seconds)
135
131
  expire_time = Time.now.to_i + expired_in_seconds
136
132
 
137
- Utils.clean_object_name!(key)
138
133
  signature = Authorization.get_temporary_signature(
139
134
  @secret_key,
140
135
  expire_time,
@@ -155,7 +150,6 @@ module Aliyun
155
150
  #
156
151
  # @return [Response]
157
152
  def bucket_delete_object(key)
158
- Utils.clean_object_name!(key)
159
153
  http.delete("/#{key}", bucket: bucket, key: key)
160
154
  end
161
155
 
@@ -190,7 +184,6 @@ module Aliyun
190
184
  #
191
185
  # @return [Response]
192
186
  def bucket_get_meta_object(key, headers = {})
193
- Utils.clean_object_name!(key)
194
187
  Utils.stringify_keys!(headers)
195
188
  http.head("/#{key}", headers: headers, bucket: bucket, key: key)
196
189
  end
@@ -205,7 +198,6 @@ module Aliyun
205
198
  #
206
199
  # @return [Response]
207
200
  def bucket_get_object_acl(key)
208
- Utils.clean_object_name!(key)
209
201
  query = { 'acl' => true }
210
202
  http.get("/#{key}", query: query, bucket: bucket, key: key)
211
203
  end
@@ -221,7 +213,6 @@ module Aliyun
221
213
  #
222
214
  # @return [Response]
223
215
  def bucket_set_object_acl(key, acl)
224
- Utils.clean_object_name!(key)
225
216
  query = { 'acl' => true }
226
217
  headers = { 'x-oss-object-acl' => acl }
227
218
  http.put("/#{key}", query: query, headers: headers, bucket: bucket, key: key)
@@ -13,31 +13,31 @@ module Aliyun
13
13
  @host = host
14
14
  end
15
15
 
16
- def get(uri, options = {})
17
- request('GET', uri, options)
16
+ def get(path, options = {})
17
+ request('GET', path, options)
18
18
  end
19
19
 
20
- def put(uri, options = {})
20
+ def put(path, options = {})
21
21
  headers = default_content_type.merge(options[:headers] || {})
22
- request('PUT', uri, options.merge(headers: headers))
22
+ request('PUT', path, options.merge(headers: headers))
23
23
  end
24
24
 
25
- def post(uri, options = {})
25
+ def post(path, options = {})
26
26
  headers = default_content_type.merge(options[:headers] || {})
27
- request('POST', uri, options.merge(headers: headers))
27
+ request('POST', path, options.merge(headers: headers))
28
28
  end
29
29
 
30
- def delete(uri, options = {})
30
+ def delete(path, options = {})
31
31
  headers = default_content_type.merge(options[:headers] || {})
32
- request('DELETE', uri, options.merge(headers: headers))
32
+ request('DELETE', path, options.merge(headers: headers))
33
33
  end
34
34
 
35
- def options(uri, options = {})
36
- request('OPTIONS', uri, options)
35
+ def options(path, options = {})
36
+ request('OPTIONS', path, options)
37
37
  end
38
38
 
39
- def head(uri, options = {})
40
- request('HEAD', uri, options)
39
+ def head(path, options = {})
40
+ request('HEAD', path, options)
41
41
  end
42
42
 
43
43
  private
@@ -49,7 +49,7 @@ module Aliyun
49
49
 
50
50
  append_headers!(headers, verb, body, options)
51
51
 
52
- path = api_endpoint(headers['Host']) + resource
52
+ path = get_path(headers['Host'], resource)
53
53
  options = { headers: headers, query: query, body: body, uri_adapter: Addressable::URI }
54
54
 
55
55
  wrap(HTTParty.__send__(verb.downcase, path, options))
@@ -128,6 +128,11 @@ module Aliyun
128
128
  "http://#{host}"
129
129
  end
130
130
 
131
+ def get_path(host, resource)
132
+ fixed = resource.split('/').map { |res| CGI.escape(res) }.join('/')
133
+ api_endpoint(host) + fixed
134
+ end
135
+
131
136
  def user_agent
132
137
  "aliyun-oss-sdk-ruby/#{Aliyun::Oss::VERSION} " \
133
138
  "(#{RbConfig::CONFIG['host_os']} ruby-#{RbConfig::CONFIG['ruby_version']})"
@@ -7,11 +7,6 @@ module Aliyun
7
7
  module Oss
8
8
  class Utils
9
9
 
10
- # remove special charaters in object name https://github.com/aliyun-beta/aliyun-oss-ruby-sdk/issues/9
11
- def self.clean_object_name!(key)
12
- key.gsub!(/[#%]/, '')
13
- end
14
-
15
10
  # Get endpoint
16
11
  #
17
12
  # @example
@@ -1,5 +1,5 @@
1
1
  module Aliyun
2
2
  module Oss
3
- VERSION = '0.1.7'
3
+ VERSION = '0.1.8'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aliyun-oss-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Newell Zhu