aliyun-sdk 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +0 -0
  4. data/examples/aliyun/oss/bucket.rb +0 -0
  5. data/examples/aliyun/oss/callback.rb +0 -0
  6. data/examples/aliyun/oss/object.rb +0 -0
  7. data/examples/aliyun/oss/resumable_download.rb +0 -0
  8. data/examples/aliyun/oss/resumable_upload.rb +0 -0
  9. data/examples/aliyun/oss/streaming.rb +0 -0
  10. data/examples/aliyun/oss/using_sts.rb +0 -0
  11. data/examples/aliyun/sts/assume_role.rb +0 -0
  12. data/ext/crcx/crc64_ecma.c +0 -0
  13. data/ext/crcx/crcx.c +0 -0
  14. data/ext/crcx/crcx.h +0 -0
  15. data/ext/crcx/extconf.rb +0 -0
  16. data/lib/aliyun/common.rb +0 -0
  17. data/lib/aliyun/common/exception.rb +0 -0
  18. data/lib/aliyun/common/logging.rb +0 -0
  19. data/lib/aliyun/common/struct.rb +0 -0
  20. data/lib/aliyun/oss.rb +0 -0
  21. data/lib/aliyun/oss/bucket.rb +28 -32
  22. data/lib/aliyun/oss/client.rb +6 -2
  23. data/lib/aliyun/oss/config.rb +0 -0
  24. data/lib/aliyun/oss/download.rb +0 -0
  25. data/lib/aliyun/oss/exception.rb +0 -0
  26. data/lib/aliyun/oss/http.rb +8 -10
  27. data/lib/aliyun/oss/iterator.rb +0 -0
  28. data/lib/aliyun/oss/multipart.rb +0 -0
  29. data/lib/aliyun/oss/object.rb +0 -0
  30. data/lib/aliyun/oss/protocol.rb +17 -3
  31. data/lib/aliyun/oss/struct.rb +2 -2
  32. data/lib/aliyun/oss/upload.rb +0 -0
  33. data/lib/aliyun/oss/util.rb +6 -0
  34. data/lib/aliyun/sts.rb +0 -0
  35. data/lib/aliyun/sts/client.rb +1 -1
  36. data/lib/aliyun/sts/config.rb +0 -0
  37. data/lib/aliyun/sts/exception.rb +0 -0
  38. data/lib/aliyun/sts/protocol.rb +1 -1
  39. data/lib/aliyun/sts/struct.rb +0 -0
  40. data/lib/aliyun/sts/util.rb +0 -0
  41. data/lib/aliyun/version.rb +1 -1
  42. data/spec/aliyun/oss/bucket_spec.rb +0 -0
  43. data/spec/aliyun/oss/client/bucket_spec.rb +4 -1
  44. data/spec/aliyun/oss/client/client_spec.rb +25 -0
  45. data/spec/aliyun/oss/client/resumable_download_spec.rb +0 -0
  46. data/spec/aliyun/oss/client/resumable_upload_spec.rb +0 -0
  47. data/spec/aliyun/oss/http_spec.rb +0 -0
  48. data/spec/aliyun/oss/multipart_spec.rb +0 -0
  49. data/spec/aliyun/oss/object_spec.rb +17 -0
  50. data/spec/aliyun/oss/service_spec.rb +0 -0
  51. data/spec/aliyun/oss/util_spec.rb +51 -0
  52. data/spec/aliyun/sts/client_spec.rb +0 -0
  53. data/spec/aliyun/sts/util_spec.rb +0 -0
  54. data/tests/config.rb +0 -0
  55. data/tests/helper.rb +0 -0
  56. data/tests/test_content_encoding.rb +0 -0
  57. data/tests/test_content_type.rb +0 -0
  58. data/tests/test_crc_check.rb +0 -0
  59. data/tests/test_custom_headers.rb +0 -0
  60. data/tests/test_encoding.rb +0 -0
  61. data/tests/test_large_file.rb +0 -0
  62. data/tests/test_multipart.rb +0 -0
  63. data/tests/test_object_acl.rb +0 -0
  64. data/tests/test_object_key.rb +18 -0
  65. data/tests/test_object_url.rb +20 -0
  66. data/tests/test_resumable.rb +0 -0
  67. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0eb63cbc2eaef6904f149227af4fe4aadaf492b3
4
- data.tar.gz: c77132cb5b467b459f84641ede4ae9335d626ff1
2
+ SHA256:
3
+ metadata.gz: aea256f156d30bf7e84ed0f6a2cd0670b63c02fe1fc6a6f9641e479dc2dfcbf5
4
+ data.tar.gz: 1344db0e4aa351fc9065779ef80297857a57e48fdf5d41527dd5ce3cb62c17cb
5
5
  SHA512:
6
- metadata.gz: befbf2ca1b3b80e69d58fcea1c4c6d2dcab38499cfecd2aa4f8c8827b098b5ab912a7efe388b8d24e6ace7a065f0eb2a4464b0be713190c5d7120020fab57bc5
7
- data.tar.gz: 9c1384ed6d63ba3a71634276b48dbe04e757fc865152f9fcd9bb52e3cb7a750e30afd8d519aebaafc60157be35845d6e315e6087e795125398b2e62ea6727356
6
+ metadata.gz: 53387168b68b6b209f8a2c83e7704c0b0fa5bc02cb7dcd384c19bfe357eece672a5e9b2e566e2da261d1133d5a99280455e74eb71ef3aa09158659948b3fb2bf
7
+ data.tar.gz: 93615f26a714a0daf08cfe18addd2fc25bc5e1d028ec53ab8302f6aeabd4e4b05dc59f254cc823faeba2d846f0b0b8e5a74736fc9348ee1ee6d88366b100cc84
@@ -1,5 +1,13 @@
1
1
  ## Change Log
2
2
 
3
+ ### v0.7.1 / 2019-11-16
4
+
5
+ - add the validity check of bucket name
6
+ - add parameters argument for buclet.object_url api
7
+ - fix http.get_request_url function bug
8
+ - fix warning constant ::Fixnum is deprecated
9
+ - support rest-client 2.1.0
10
+
3
11
  ### v0.7.0 / 2018-06-05
4
12
 
5
13
  - deps: upgrade nokogiri to > 1.6 and ruby version >= 2.0
data/README.md CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -588,42 +588,38 @@ module Aliyun
588
588
  # 获取Object的URL
589
589
  # @param [String] key Object的key
590
590
  # @param [Boolean] sign 是否对URL进行签名,默认为是
591
- # @param [Fixnum] expiry URL的有效时间,单位为秒,默认为60s
591
+ # @param [Integer] expiry URL的有效时间,单位为秒,默认为60s
592
+ # @param [Hash] parameters 附加的query参数,默认为空
592
593
  # @return [String] 用于直接访问Object的URL
593
- def object_url(key, sign = true, expiry = 60)
594
- url = @protocol.get_request_url(name, key)
595
- return url unless sign
596
-
597
- expires = Time.now.to_i + expiry
598
- query = {
599
- 'Expires' => expires.to_s,
600
- 'OSSAccessKeyId' => CGI.escape(access_key_id)
601
- }
602
-
603
- sub_res = []
604
- if @protocol.get_sts_token
605
- sub_res << "security-token=#{@protocol.get_sts_token}"
606
- query['security-token'] = CGI.escape(@protocol.get_sts_token)
607
- end
608
-
609
- resource = "/#{name}/#{key}"
610
- unless sub_res.empty?
611
- resource << (resource.include?('?') ? "&#{sub_res.join('&')}" : "?#{sub_res.join('&')}")
612
- end
594
+ def object_url(key, sign = true, expiry = 60, parameters = {})
595
+ url = @protocol.get_request_url(name, key).gsub('%2F', '/')
596
+ query = parameters.dup
597
+
598
+ if sign
599
+ #header
600
+ expires = Time.now.to_i + expiry
601
+ headers = {
602
+ 'date' => expires.to_s,
603
+ }
604
+
605
+ #query
606
+ if @protocol.get_sts_token
607
+ query['security-token'] = @protocol.get_sts_token
608
+ end
613
609
 
614
- string_to_sign = "" <<
615
- "GET\n" << # method
616
- "\n" << # Content-MD5
617
- "\n" << # Content-Type
618
- "#{expires}\n" <<
619
- "#{resource}"
610
+ res = {
611
+ :path => @protocol.get_resource_path(name, key),
612
+ :sub_res => query,
613
+ }
614
+ signature = Util.get_signature(@protocol.get_access_key_secret, 'GET', headers, res)
620
615
 
621
- signature = sign(string_to_sign)
622
- query_string =
623
- query.merge('Signature' => CGI.escape(signature))
624
- .map { |k, v| "#{k}=#{v}" }.join('&')
616
+ query['Expires'] = expires.to_s
617
+ query['OSSAccessKeyId'] = @protocol.get_access_key_id
618
+ query['Signature'] = signature
619
+ end
625
620
 
626
- link_char = url.include?('?') ? '&' : '?'
621
+ query_string = query.map { |k, v| v ? [k, CGI.escape(v)].join("=") : k }.join("&")
622
+ link_char = query_string.empty? ? '' : '?'
627
623
  [url, query_string].join(link_char)
628
624
  end
629
625
 
@@ -34,9 +34,9 @@ module Aliyun
34
34
  # 是否开启CRC校验,默认为不开启(false)
35
35
  # @option opts [String] :sts_token [可选] 指定STS的
36
36
  # SecurityToken,如果指定,则使用STS授权访问
37
- # @option opts [Fixnum] :open_timeout [可选] 指定建立连接的超时
37
+ # @option opts [Integer] :open_timeout [可选] 指定建立连接的超时
38
38
  # 时间,默认为10秒
39
- # @option opts [Fixnum] :read_timeout [可选] 指定等待响应的超时
39
+ # @option opts [Integer] :read_timeout [可选] 指定等待响应的超时
40
40
  # 时间,默认为120秒
41
41
  # @example 标准endpoint
42
42
  # oss-cn-hangzhou.aliyuncs.com
@@ -70,6 +70,7 @@ module Aliyun
70
70
  # @param opts [Hash] 创建Bucket的属性(可选)
71
71
  # @option opts [:location] [String] 指定bucket所在的区域,默认为oss-cn-hangzhou
72
72
  def create_bucket(name, opts = {})
73
+ Util.ensure_bucket_name_valid(name)
73
74
  @protocol.create_bucket(name, opts)
74
75
  end
75
76
 
@@ -77,6 +78,7 @@ module Aliyun
77
78
  # @param name [String] Bucket名字
78
79
  # @note 如果要删除的Bucket不为空(包含有object),则删除会失败
79
80
  def delete_bucket(name)
81
+ Util.ensure_bucket_name_valid(name)
80
82
  @protocol.delete_bucket(name)
81
83
  end
82
84
 
@@ -84,6 +86,7 @@ module Aliyun
84
86
  # @param name [String] Bucket名字
85
87
  # @return [Boolean] 如果Bucket存在则返回true,否则返回false
86
88
  def bucket_exists?(name)
89
+ Util.ensure_bucket_name_valid(name)
87
90
  exist = false
88
91
 
89
92
  begin
@@ -102,6 +105,7 @@ module Aliyun
102
105
  # @param name [String] Bucket名字
103
106
  # @return [Bucket] Bucket对象
104
107
  def get_bucket(name)
108
+ Util.ensure_bucket_name_valid(name)
105
109
  Bucket.new({:name => name}, @protocol)
106
110
  end
107
111
 
File without changes
File without changes
File without changes
@@ -121,17 +121,13 @@ module Aliyun
121
121
 
122
122
  def get_request_url(bucket, object)
123
123
  url = @config.endpoint.dup
124
+ url.query = nil
125
+ url.fragment = nil
124
126
  isIP = !!(url.host =~ Resolv::IPv4::Regex)
125
127
  url.host = "#{bucket}." + url.host if bucket && !@config.cname && !isIP
126
128
  url.path = '/'
127
129
  url.path << "#{bucket}/" if bucket && isIP
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
134
-
130
+ url.path << CGI.escape(object) if object
135
131
  url.to_s
136
132
  end
137
133
 
@@ -285,9 +281,11 @@ module Aliyun
285
281
  # RestClient::Response ourselves
286
282
  unless response.is_a?(RestClient::Response)
287
283
  if response.code.to_i >= 300
288
- response = RestClient::Response.create(
289
- RestClient::Request.decode(response['content-encoding'], response.body),
290
- response, request)
284
+ body = response.body
285
+ if RestClient::version < '2.1.0'
286
+ body = RestClient::Request.decode(response['content-encoding'], response.body)
287
+ end
288
+ response = RestClient::Response.create(body, response, request)
291
289
  e = ServerError.new(response)
292
290
  logger.error(e.to_s)
293
291
  raise e
File without changes
File without changes
File without changes
@@ -346,10 +346,10 @@ module Aliyun
346
346
  xml.Date Time.utc(
347
347
  r.expiry.year, r.expiry.month, r.expiry.day)
348
348
  .iso8601.sub('Z', '.000Z')
349
- elsif r.expiry.is_a?(Fixnum)
349
+ elsif r.expiry.is_a?(Integer)
350
350
  xml.Days r.expiry
351
351
  else
352
- fail ClientError, "Expiry must be a Date or Fixnum."
352
+ fail ClientError, "Expiry must be a Date or Integer."
353
353
  end
354
354
  }
355
355
  }
@@ -1394,12 +1394,26 @@ module Aliyun
1394
1394
  @http.get_request_url(bucket, object)
1395
1395
  end
1396
1396
 
1397
+ # Get bucket/object resource path
1398
+ # @param [String] bucket the bucket name
1399
+ # @param [String] object the bucket name
1400
+ # @return [String] resource path for the bucket/object
1401
+ def get_resource_path(bucket, object = nil)
1402
+ @http.get_resource_path(bucket, object)
1403
+ end
1404
+
1397
1405
  # Get user's access key id
1398
1406
  # @return [String] the access key id
1399
1407
  def get_access_key_id
1400
1408
  @config.access_key_id
1401
1409
  end
1402
1410
 
1411
+ # Get user's access key secret
1412
+ # @return [String] the access key secret
1413
+ def get_access_key_secret
1414
+ @config.access_key_secret
1415
+ end
1416
+
1403
1417
  # Get user's STS token
1404
1418
  # @return [String] the STS token
1405
1419
  def get_sts_token
@@ -1517,7 +1531,7 @@ module Aliyun
1517
1531
  def get_bytes_range(range)
1518
1532
  if range &&
1519
1533
  (!range.is_a?(Array) || range.size != 2 ||
1520
- !range.at(0).is_a?(Fixnum) || !range.at(1).is_a?(Fixnum))
1534
+ !range.at(0).is_a?(Integer) || !range.at(1).is_a?(Integer))
1521
1535
  fail ClientError, "Range must be an array containing 2 Integers."
1522
1536
  end
1523
1537
 
@@ -107,10 +107,10 @@ module Aliyun
107
107
  # * id [String] the unique id of a rule
108
108
  # * enabled [Boolean] whether to enable this rule
109
109
  # * prefix [String] the prefix objects to apply this rule
110
- # * expiry [Date] or [Fixnum] the expire time of objects
110
+ # * expiry [Date] or [Integer] the expire time of objects
111
111
  # * if expiry is a Date, it specifies the absolute date to
112
112
  # expire objects
113
- # * if expiry is a Fixnum, it specifies the relative date to
113
+ # * if expiry is a Integer, it specifies the relative date to
114
114
  # expire objects: how many days after the object's last
115
115
  # modification time to expire the object
116
116
  # @example Specify expiry as Date
File without changes
@@ -93,6 +93,12 @@ module Aliyun
93
93
  end
94
94
  end
95
95
 
96
+ def ensure_bucket_name_valid(name)
97
+ unless (name =~ %r|^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$|)
98
+ fail ClientError, "The bucket name is invalid."
99
+ end
100
+ end
101
+
96
102
  end # self
97
103
  end # Util
98
104
  end # OSS
File without changes
@@ -25,7 +25,7 @@ module Aliyun
25
25
  # @param role [String] the role arn
26
26
  # @param session [String] the session name
27
27
  # @param policy [STS::Policy] the policy
28
- # @param duration [Fixnum] the duration seconds for the
28
+ # @param duration [Integer] the duration seconds for the
29
29
  # requested token
30
30
  # @return [STS::Token] the sts token
31
31
  def assume_role(role, session, policy = nil, duration = 3600)
File without changes
File without changes
@@ -27,7 +27,7 @@ module Aliyun
27
27
  # @param role [String] the role arn
28
28
  # @param session [String] the session name
29
29
  # @param policy [STS::Policy] the policy
30
- # @param duration [Fixnum] the duration seconds for the
30
+ # @param duration [Integer] the duration seconds for the
31
31
  # requested token
32
32
  # @return [STS::Token] the sts token
33
33
  def assume_role(role, session, policy = nil, duration = 3600)
File without changes
File without changes
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Aliyun
4
4
 
5
- VERSION = "0.7.0"
5
+ VERSION = "0.7.1"
6
6
 
7
7
  end # Aliyun
File without changes
@@ -498,7 +498,10 @@ module Aliyun
498
498
  :access_key_secret => 'yyy',
499
499
  :sts_token => 'zzz').get_bucket(@bucket_name)
500
500
 
501
- url = sts_bucket.object_url('ico.png?x-oss-process=image/resize,m_fill,h_100,w_100')
501
+ param = {
502
+ 'x-oss-process' => 'image/resize,m_fill,h_100,w_100',
503
+ }
504
+ url = sts_bucket.object_url('ico.png', true, 60, param)
502
505
  path = url[0, url.index('?')]
503
506
  expect(path).to eq('http://rubysdk-bucket.oss-cn-hangzhou.aliyuncs.com/ico.png')
504
507
 
@@ -127,6 +127,31 @@ module Aliyun
127
127
  expect(WebMock).to have_requested(:get, "#{bucket}.#{ep1}/#{object}")
128
128
  expect(WebMock).to have_requested(:put, "#{bucket}.#{ep2}/#{object}")
129
129
  end
130
+
131
+ it "should fail with invalid bucket name" do
132
+ bucket = 'INVALID'
133
+ ep1 = 'oss-cn-hangzhou.aliyuncs.com'
134
+ client = Client.new(
135
+ :endpoint => ep1,
136
+ :access_key_id => 'xxx', :access_key_secret => 'yyy')
137
+
138
+ expect {
139
+ client.create_bucket(bucket)
140
+ }.to raise_error(ClientError, "The bucket name is invalid.")
141
+
142
+ expect {
143
+ client.delete_bucket(bucket)
144
+ }.to raise_error(ClientError, "The bucket name is invalid.")
145
+
146
+ expect {
147
+ client.bucket_exists?(bucket)
148
+ }.to raise_error(ClientError, "The bucket name is invalid.")
149
+
150
+ expect {
151
+ client.get_bucket(bucket)
152
+ }.to raise_error(ClientError, "The bucket name is invalid.")
153
+ end
154
+
130
155
  end # construct
131
156
 
132
157
  def mock_buckets(buckets, more = {})
File without changes
File without changes
@@ -710,6 +710,23 @@ module Aliyun
710
710
  'Range' => 'bytes=0-9'
711
711
  })
712
712
  end
713
+
714
+ it "should get to get object with special chars" do
715
+ object_name = 'ruby///adfadfa//!@#%^*//?key=value&aabc#abc=ad'
716
+ url = get_request_path(object_name)
717
+
718
+ return_content = "hello world"
719
+ stub_request(:get, url).to_return(:body => return_content)
720
+
721
+ content = ""
722
+ @protocol.get_object(@bucket, object_name) {|c| content << c}
723
+
724
+ expect(WebMock).to have_requested(:get, url)
725
+ .with(:body => nil, :query => {})
726
+
727
+ expect(content).to eq(return_content)
728
+ end
729
+
713
730
  end # Get object
714
731
 
715
732
  context "Get object meta" do
File without changes
@@ -94,6 +94,57 @@ module Aliyun
94
94
  }.to raise_error(CrcInconsistentError, "The crc of post between client and oss is not inconsistent.")
95
95
  end
96
96
 
97
+ it "should check bucket name valid" do
98
+ expect {
99
+ Util.ensure_bucket_name_valid('abc')
100
+ }.not_to raise_error
101
+
102
+ expect {
103
+ Util.ensure_bucket_name_valid('abc123-321cba')
104
+ }.not_to raise_error
105
+
106
+ expect {
107
+ Util.ensure_bucket_name_valid('abcdefghijklmnopqrstuvwxyz1234567890-0987654321zyxwuvtsrqponmlk')
108
+ }.not_to raise_error
109
+
110
+ #>63
111
+ expect {
112
+ Util.ensure_bucket_name_valid('abcdefghijklmnopqrstuvwxyz1234567890-0987654321zyxwuvtsrqponmlkj')
113
+ }.to raise_error(ClientError, "The bucket name is invalid.")
114
+
115
+ #<3
116
+ expect {
117
+ Util.ensure_bucket_name_valid('12')
118
+ }.to raise_error(ClientError, "The bucket name is invalid.")
119
+
120
+ #not [a-z0-9-]
121
+ expect {
122
+ Util.ensure_bucket_name_valid('Aabc')
123
+ }.to raise_error(ClientError, "The bucket name is invalid.")
124
+
125
+ expect {
126
+ Util.ensure_bucket_name_valid('abc/')
127
+ }.to raise_error(ClientError, "The bucket name is invalid.")
128
+
129
+ expect {
130
+ Util.ensure_bucket_name_valid('abc#')
131
+ }.to raise_error(ClientError, "The bucket name is invalid.")
132
+
133
+ expect {
134
+ Util.ensure_bucket_name_valid('abc?')
135
+ }.to raise_error(ClientError, "The bucket name is invalid.")
136
+
137
+ #start & end not -
138
+ expect {
139
+ Util.ensure_bucket_name_valid('-abc')
140
+ }.to raise_error(ClientError, "The bucket name is invalid.")
141
+
142
+ expect {
143
+ Util.ensure_bucket_name_valid('abc-')
144
+ }.to raise_error(ClientError, "The bucket name is invalid.")
145
+
146
+ end
147
+
97
148
  end # Util
98
149
 
99
150
  end # OSS
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -17,6 +17,8 @@ class TestObjectKey < Minitest::Test
17
17
  chinese: '杭州・中国',
18
18
  space: '是 空格 yeah +-/\\&*#',
19
19
  invisible: '' << 1 << 10 << 12 << 7 << 80 << 99,
20
+ specail1: 'testkey/',
21
+ specail2: 'testkey/?key=value#abc=def',
20
22
  xml: 'a<b&c>d +'
21
23
  }
22
24
  end
@@ -57,6 +59,22 @@ class TestObjectKey < Minitest::Test
57
59
  assert_equal key, @bucket.get_object(key).key
58
60
  end
59
61
 
62
+ def test_specail1
63
+ key = get_key(:specail1)
64
+ @bucket.put_object(key)
65
+ all = @bucket.list_objects(prefix: @prefix).map(&:key)
66
+ assert_includes all, key
67
+ assert_equal key, @bucket.get_object(key).key
68
+ end
69
+
70
+ def test_specail2
71
+ key = get_key(:specail2)
72
+ @bucket.put_object(key)
73
+ all = @bucket.list_objects(prefix: @prefix).map(&:key)
74
+ assert_includes all, key
75
+ assert_equal key, @bucket.get_object(key).key
76
+ end
77
+
60
78
  def test_batch_delete
61
79
  keys = @keys.map { |k, _| get_key(k) }
62
80
  keys.each { |k| @bucket.put_object(k) }
@@ -66,4 +66,24 @@ class TestObjectUrl < Minitest::Test
66
66
 
67
67
  assert_equal 200, r.code
68
68
  end
69
+
70
+ def test_signed_url_with_parameters
71
+ key = get_key('example.jpg')
72
+
73
+ @bucket.put_object(key, :file => 'tests/example.jpg', acl: Aliyun::OSS::ACL::PRIVATE)
74
+
75
+ meta = @bucket.get_object(key)
76
+ assert_equal 21839, meta.size
77
+
78
+ parameters = {
79
+ 'x-oss-process' => 'image/resize,m_fill,h_100,w_100',
80
+ }
81
+ signed_url = @bucket.object_url(key, true, 60, parameters)
82
+ r = RestClient.get(signed_url)
83
+ lenth = r.headers[:content_length].to_i
84
+ assert_equal 200, r.code
85
+ assert_equal true, lenth < meta.size
86
+
87
+ end
88
+
69
89
  end
File without changes
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.7.0
4
+ version: 0.7.1
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: 2018-06-05 00:00:00.000000000 Z
11
+ date: 2019-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -230,8 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  - !ruby/object:Gem::Version
231
231
  version: '0'
232
232
  requirements: []
233
- rubyforge_project:
234
- rubygems_version: 2.5.2
233
+ rubygems_version: 3.0.3
235
234
  signing_key:
236
235
  specification_version: 4
237
236
  summary: Aliyun OSS SDK for Ruby