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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +8 -0
- data/README.md +0 -0
- data/examples/aliyun/oss/bucket.rb +0 -0
- data/examples/aliyun/oss/callback.rb +0 -0
- data/examples/aliyun/oss/object.rb +0 -0
- data/examples/aliyun/oss/resumable_download.rb +0 -0
- data/examples/aliyun/oss/resumable_upload.rb +0 -0
- data/examples/aliyun/oss/streaming.rb +0 -0
- data/examples/aliyun/oss/using_sts.rb +0 -0
- data/examples/aliyun/sts/assume_role.rb +0 -0
- data/ext/crcx/crc64_ecma.c +0 -0
- data/ext/crcx/crcx.c +0 -0
- data/ext/crcx/crcx.h +0 -0
- data/ext/crcx/extconf.rb +0 -0
- data/lib/aliyun/common.rb +0 -0
- data/lib/aliyun/common/exception.rb +0 -0
- data/lib/aliyun/common/logging.rb +0 -0
- data/lib/aliyun/common/struct.rb +0 -0
- data/lib/aliyun/oss.rb +0 -0
- data/lib/aliyun/oss/bucket.rb +28 -32
- data/lib/aliyun/oss/client.rb +6 -2
- data/lib/aliyun/oss/config.rb +0 -0
- data/lib/aliyun/oss/download.rb +0 -0
- data/lib/aliyun/oss/exception.rb +0 -0
- data/lib/aliyun/oss/http.rb +8 -10
- data/lib/aliyun/oss/iterator.rb +0 -0
- data/lib/aliyun/oss/multipart.rb +0 -0
- data/lib/aliyun/oss/object.rb +0 -0
- data/lib/aliyun/oss/protocol.rb +17 -3
- data/lib/aliyun/oss/struct.rb +2 -2
- data/lib/aliyun/oss/upload.rb +0 -0
- data/lib/aliyun/oss/util.rb +6 -0
- data/lib/aliyun/sts.rb +0 -0
- data/lib/aliyun/sts/client.rb +1 -1
- data/lib/aliyun/sts/config.rb +0 -0
- data/lib/aliyun/sts/exception.rb +0 -0
- data/lib/aliyun/sts/protocol.rb +1 -1
- data/lib/aliyun/sts/struct.rb +0 -0
- data/lib/aliyun/sts/util.rb +0 -0
- data/lib/aliyun/version.rb +1 -1
- data/spec/aliyun/oss/bucket_spec.rb +0 -0
- data/spec/aliyun/oss/client/bucket_spec.rb +4 -1
- data/spec/aliyun/oss/client/client_spec.rb +25 -0
- data/spec/aliyun/oss/client/resumable_download_spec.rb +0 -0
- data/spec/aliyun/oss/client/resumable_upload_spec.rb +0 -0
- data/spec/aliyun/oss/http_spec.rb +0 -0
- data/spec/aliyun/oss/multipart_spec.rb +0 -0
- data/spec/aliyun/oss/object_spec.rb +17 -0
- data/spec/aliyun/oss/service_spec.rb +0 -0
- data/spec/aliyun/oss/util_spec.rb +51 -0
- data/spec/aliyun/sts/client_spec.rb +0 -0
- data/spec/aliyun/sts/util_spec.rb +0 -0
- data/tests/config.rb +0 -0
- data/tests/helper.rb +0 -0
- data/tests/test_content_encoding.rb +0 -0
- data/tests/test_content_type.rb +0 -0
- data/tests/test_crc_check.rb +0 -0
- data/tests/test_custom_headers.rb +0 -0
- data/tests/test_encoding.rb +0 -0
- data/tests/test_large_file.rb +0 -0
- data/tests/test_multipart.rb +0 -0
- data/tests/test_object_acl.rb +0 -0
- data/tests/test_object_key.rb +18 -0
- data/tests/test_object_url.rb +20 -0
- data/tests/test_resumable.rb +0 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: aea256f156d30bf7e84ed0f6a2cd0670b63c02fe1fc6a6f9641e479dc2dfcbf5
|
4
|
+
data.tar.gz: 1344db0e4aa351fc9065779ef80297857a57e48fdf5d41527dd5ce3cb62c17cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53387168b68b6b209f8a2c83e7704c0b0fa5bc02cb7dcd384c19bfe357eece672a5e9b2e566e2da261d1133d5a99280455e74eb71ef3aa09158659948b3fb2bf
|
7
|
+
data.tar.gz: 93615f26a714a0daf08cfe18addd2fc25bc5e1d028ec53ab8302f6aeabd4e4b05dc59f254cc823faeba2d846f0b0b8e5a74736fc9348ee1ee6d88366b100cc84
|
data/CHANGELOG.md
CHANGED
@@ -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
|
data/ext/crcx/crc64_ecma.c
CHANGED
File without changes
|
data/ext/crcx/crcx.c
CHANGED
File without changes
|
data/ext/crcx/crcx.h
CHANGED
File without changes
|
data/ext/crcx/extconf.rb
CHANGED
File without changes
|
data/lib/aliyun/common.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/lib/aliyun/common/struct.rb
CHANGED
File without changes
|
data/lib/aliyun/oss.rb
CHANGED
File without changes
|
data/lib/aliyun/oss/bucket.rb
CHANGED
@@ -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 [
|
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
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
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
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
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
|
-
|
622
|
-
|
623
|
-
query
|
624
|
-
|
616
|
+
query['Expires'] = expires.to_s
|
617
|
+
query['OSSAccessKeyId'] = @protocol.get_access_key_id
|
618
|
+
query['Signature'] = signature
|
619
|
+
end
|
625
620
|
|
626
|
-
|
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
|
|
data/lib/aliyun/oss/client.rb
CHANGED
@@ -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 [
|
37
|
+
# @option opts [Integer] :open_timeout [可选] 指定建立连接的超时
|
38
38
|
# 时间,默认为10秒
|
39
|
-
# @option opts [
|
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
|
|
data/lib/aliyun/oss/config.rb
CHANGED
File without changes
|
data/lib/aliyun/oss/download.rb
CHANGED
File without changes
|
data/lib/aliyun/oss/exception.rb
CHANGED
File without changes
|
data/lib/aliyun/oss/http.rb
CHANGED
@@ -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
|
-
|
289
|
-
|
290
|
-
response,
|
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
|
data/lib/aliyun/oss/iterator.rb
CHANGED
File without changes
|
data/lib/aliyun/oss/multipart.rb
CHANGED
File without changes
|
data/lib/aliyun/oss/object.rb
CHANGED
File without changes
|
data/lib/aliyun/oss/protocol.rb
CHANGED
@@ -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?(
|
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
|
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?(
|
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
|
|
data/lib/aliyun/oss/struct.rb
CHANGED
@@ -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 [
|
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
|
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
|
data/lib/aliyun/oss/upload.rb
CHANGED
File without changes
|
data/lib/aliyun/oss/util.rb
CHANGED
data/lib/aliyun/sts.rb
CHANGED
File without changes
|
data/lib/aliyun/sts/client.rb
CHANGED
@@ -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 [
|
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)
|
data/lib/aliyun/sts/config.rb
CHANGED
File without changes
|
data/lib/aliyun/sts/exception.rb
CHANGED
File without changes
|
data/lib/aliyun/sts/protocol.rb
CHANGED
@@ -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 [
|
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)
|
data/lib/aliyun/sts/struct.rb
CHANGED
File without changes
|
data/lib/aliyun/sts/util.rb
CHANGED
File without changes
|
data/lib/aliyun/version.rb
CHANGED
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
|
-
|
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
|
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
|
data/tests/config.rb
CHANGED
File without changes
|
data/tests/helper.rb
CHANGED
File without changes
|
File without changes
|
data/tests/test_content_type.rb
CHANGED
File without changes
|
data/tests/test_crc_check.rb
CHANGED
File without changes
|
File without changes
|
data/tests/test_encoding.rb
CHANGED
File without changes
|
data/tests/test_large_file.rb
CHANGED
File without changes
|
data/tests/test_multipart.rb
CHANGED
File without changes
|
data/tests/test_object_acl.rb
CHANGED
File without changes
|
data/tests/test_object_key.rb
CHANGED
@@ -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) }
|
data/tests/test_object_url.rb
CHANGED
@@ -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
|
data/tests/test_resumable.rb
CHANGED
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.
|
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:
|
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
|
-
|
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
|