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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b400456da8877a797a2caecc64fd696f54f129f3
4
- data.tar.gz: 0bc030c00b7bc81a234bfa7ac52db10a1cbc7f71
3
+ metadata.gz: 0eb63cbc2eaef6904f149227af4fe4aadaf492b3
4
+ data.tar.gz: c77132cb5b467b459f84641ede4ae9335d626ff1
5
5
  SHA512:
6
- metadata.gz: 71786966777a2ebcbbdf370bf436c8d5d983e710f0fca4f2f2c7e63ea8dab9fc51982b457a4cdfeeb3085cb4509260cd8646b15de374bd41b0ca114ae647d121
7
- data.tar.gz: b03108695f1e78fae5c0ab4dc2da904b9af2409e93d4bb0529da78a1fa10f28e1f2548165890dc7710f35b364765559ecdcc60d2e5444f9035489fb5a737e831
6
+ metadata.gz: befbf2ca1b3b80e69d58fcea1c4c6d2dcab38499cfecd2aa4f8c8827b098b5ab912a7efe388b8d24e6ace7a065f0eb2a4464b0be713190c5d7120020fab57bc5
7
+ data.tar.gz: 9c1384ed6d63ba3a71634276b48dbe04e757fc865152f9fcd9bb52e3cb7a750e30afd8d519aebaafc60157be35845d6e315e6087e795125398b2e62ea6727356
@@ -1,5 +1,9 @@
1
1
  ## Change Log
2
2
 
3
+ ### v0.7.0 / 2018-06-05
4
+
5
+ - deps: upgrade nokogiri to > 1.6 and ruby version >= 2.0
6
+
3
7
  ### v0.6.0 / 2017-07-23
4
8
 
5
9
  - deps: upgrade rest-client to 2.x
@@ -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
- [url, query_string].join('?')
626
+ link_char = url.include?('?') ? '&' : '?'
627
+ [url, query_string].join(link_char)
627
628
  end
628
629
 
629
630
  # 获取用户所设置的ACCESS_KEY_ID
@@ -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
- url.path << "#{CGI.escape(object)}" if object
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Aliyun
4
4
 
5
- VERSION = "0.6.0"
5
+ VERSION = "0.7.0"
6
6
 
7
7
  end # Aliyun
@@ -467,29 +467,52 @@ module Aliyun
467
467
  expect(signature).to eq(sig)
468
468
  end
469
469
 
470
- it "should get object url with STS" do
471
- sts_bucket = Client.new(
472
- :endpoint => @endpoint,
473
- :access_key_id => 'xxx',
474
- :access_key_secret => 'yyy',
475
- :sts_token => 'zzz').get_bucket(@bucket_name)
476
-
477
- object_url = 'http://rubysdk-bucket.oss-cn-hangzhou.aliyuncs.com/yeah'
478
-
479
- url = sts_bucket.object_url('yeah')
480
- path = url[0, url.index('?')]
481
- expect(path).to eq(object_url)
482
-
483
- query = {}
484
- url[url.index('?') + 1, url.size].split('&')
485
- .each { |s| k, v = s.split('='); query[k] = v }
486
-
487
- expect(query.key?('Expires')).to be true
488
- expect(query.key?('Signature')).to be true
489
- expect(query['OSSAccessKeyId']).to eq('xxx')
490
- expect(query['security-token']).to eq('zzz')
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.6.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: 2017-07-23 00:00:00.000000000 Z
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.2
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.2
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: 1.9.3
226
+ version: '2.0'
233
227
  required_rubygems_version: !ruby/object:Gem::Requirement
234
228
  requirements:
235
229
  - - ">="