aliyun-sdk 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/aliyun/oss/bucket.rb +3 -2
- data/lib/aliyun/oss/http.rb +6 -1
- data/lib/aliyun/version.rb +1 -1
- data/spec/aliyun/oss/client/bucket_spec.rb +45 -22
- metadata +5 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0eb63cbc2eaef6904f149227af4fe4aadaf492b3
|
4
|
+
data.tar.gz: c77132cb5b467b459f84641ede4ae9335d626ff1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: befbf2ca1b3b80e69d58fcea1c4c6d2dcab38499cfecd2aa4f8c8827b098b5ab912a7efe388b8d24e6ace7a065f0eb2a4464b0be713190c5d7120020fab57bc5
|
7
|
+
data.tar.gz: 9c1384ed6d63ba3a71634276b48dbe04e757fc865152f9fcd9bb52e3cb7a750e30afd8d519aebaafc60157be35845d6e315e6087e795125398b2e62ea6727356
|
data/CHANGELOG.md
CHANGED
data/lib/aliyun/oss/bucket.rb
CHANGED
@@ -608,7 +608,7 @@ module Aliyun
|
|
608
608
|
|
609
609
|
resource = "/#{name}/#{key}"
|
610
610
|
unless sub_res.empty?
|
611
|
-
resource << "?#{sub_res.join('&')}"
|
611
|
+
resource << (resource.include?('?') ? "&#{sub_res.join('&')}" : "?#{sub_res.join('&')}")
|
612
612
|
end
|
613
613
|
|
614
614
|
string_to_sign = "" <<
|
@@ -623,7 +623,8 @@ module Aliyun
|
|
623
623
|
query.merge('Signature' => CGI.escape(signature))
|
624
624
|
.map { |k, v| "#{k}=#{v}" }.join('&')
|
625
625
|
|
626
|
-
|
626
|
+
link_char = url.include?('?') ? '&' : '?'
|
627
|
+
[url, query_string].join(link_char)
|
627
628
|
end
|
628
629
|
|
629
630
|
# 获取用户所设置的ACCESS_KEY_ID
|
data/lib/aliyun/oss/http.rb
CHANGED
@@ -125,7 +125,12 @@ module Aliyun
|
|
125
125
|
url.host = "#{bucket}." + url.host if bucket && !@config.cname && !isIP
|
126
126
|
url.path = '/'
|
127
127
|
url.path << "#{bucket}/" if bucket && isIP
|
128
|
-
|
128
|
+
|
129
|
+
if object
|
130
|
+
path, query = object.split('?')
|
131
|
+
url.path << path.split('/').map { |seg| CGI.escape(seg) }.join('/')
|
132
|
+
url.query = query.split('&').map { |kv| k, v = kv.split('='); "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&') if query
|
133
|
+
end
|
129
134
|
|
130
135
|
url.to_s
|
131
136
|
end
|
data/lib/aliyun/version.rb
CHANGED
@@ -467,29 +467,52 @@ module Aliyun
|
|
467
467
|
expect(signature).to eq(sig)
|
468
468
|
end
|
469
469
|
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
.
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
470
|
+
context 'should use STS' do
|
471
|
+
it "get object url" do
|
472
|
+
sts_bucket = Client.new(
|
473
|
+
:endpoint => @endpoint,
|
474
|
+
:access_key_id => 'xxx',
|
475
|
+
:access_key_secret => 'yyy',
|
476
|
+
:sts_token => 'zzz').get_bucket(@bucket_name)
|
477
|
+
|
478
|
+
object_url = 'http://rubysdk-bucket.oss-cn-hangzhou.aliyuncs.com/yeah'
|
479
|
+
|
480
|
+
url = sts_bucket.object_url('yeah')
|
481
|
+
path = url[0, url.index('?')]
|
482
|
+
expect(path).to eq(object_url)
|
483
|
+
|
484
|
+
query = {}
|
485
|
+
url[url.index('?') + 1, url.size].split('&')
|
486
|
+
.each { |s| k, v = s.split('='); query[k] = v }
|
487
|
+
|
488
|
+
expect(query.key?('Expires')).to be true
|
489
|
+
expect(query.key?('Signature')).to be true
|
490
|
+
expect(query['OSSAccessKeyId']).to eq('xxx')
|
491
|
+
expect(query['security-token']).to eq('zzz')
|
492
|
+
end
|
493
|
+
|
494
|
+
it "get object url with query string" do
|
495
|
+
sts_bucket = Client.new(
|
496
|
+
:endpoint => @endpoint,
|
497
|
+
:access_key_id => 'xxx',
|
498
|
+
:access_key_secret => 'yyy',
|
499
|
+
:sts_token => 'zzz').get_bucket(@bucket_name)
|
500
|
+
|
501
|
+
url = sts_bucket.object_url('ico.png?x-oss-process=image/resize,m_fill,h_100,w_100')
|
502
|
+
path = url[0, url.index('?')]
|
503
|
+
expect(path).to eq('http://rubysdk-bucket.oss-cn-hangzhou.aliyuncs.com/ico.png')
|
504
|
+
|
505
|
+
query = {}
|
506
|
+
url[url.index('?') + 1, url.size].split('&')
|
507
|
+
.each { |s| k, v = s.split('='); query[k] = v }
|
508
|
+
|
509
|
+
expect(query.key?('Expires')).to be true
|
510
|
+
expect(query.key?('Signature')).to be true
|
511
|
+
expect(query['OSSAccessKeyId']).to eq('xxx')
|
512
|
+
expect(query['security-token']).to eq('zzz')
|
513
|
+
expect(query['x-oss-process']).to eq('image%2Fresize%2Cm_fill%2Ch_100%2Cw_100')
|
514
|
+
end
|
491
515
|
end
|
492
|
-
|
493
516
|
end # object operations
|
494
517
|
|
495
518
|
context "multipart operations" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aliyun-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tianlong Wu
|
8
8
|
autorequire:
|
9
9
|
bindir: lib/aliyun
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -17,9 +17,6 @@ dependencies:
|
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 1.7.0
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,23 +24,20 @@ dependencies:
|
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.6'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 1.7.0
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: rest-client
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - "~>"
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version: 2.0
|
33
|
+
version: '2.0'
|
40
34
|
type: :runtime
|
41
35
|
prerelease: false
|
42
36
|
version_requirements: !ruby/object:Gem::Requirement
|
43
37
|
requirements:
|
44
38
|
- - "~>"
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version: 2.0
|
40
|
+
version: '2.0'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: bundler
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,7 +223,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
229
223
|
requirements:
|
230
224
|
- - ">="
|
231
225
|
- !ruby/object:Gem::Version
|
232
|
-
version:
|
226
|
+
version: '2.0'
|
233
227
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
234
228
|
requirements:
|
235
229
|
- - ">="
|