fog-aliyun 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +149 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Rakefile +3 -3
- data/fog-aliyun.gemspec +16 -13
- data/lib/fog/aliyun.rb +8 -8
- data/lib/fog/aliyun/compute.rb +99 -113
- data/lib/fog/aliyun/models/compute/eip_address.rb +23 -29
- data/lib/fog/aliyun/models/compute/eip_addresses.rb +3 -5
- data/lib/fog/aliyun/models/compute/image.rb +26 -28
- data/lib/fog/aliyun/models/compute/images.rb +2 -6
- data/lib/fog/aliyun/models/compute/route_entry.rb +9 -11
- data/lib/fog/aliyun/models/compute/route_entrys.rb +7 -7
- data/lib/fog/aliyun/models/compute/route_table.rb +10 -11
- data/lib/fog/aliyun/models/compute/route_tables.rb +2 -2
- data/lib/fog/aliyun/models/compute/security_group.rb +24 -24
- data/lib/fog/aliyun/models/compute/security_group_rule.rb +20 -20
- data/lib/fog/aliyun/models/compute/security_group_rules.rb +4 -4
- data/lib/fog/aliyun/models/compute/security_groups.rb +6 -7
- data/lib/fog/aliyun/models/compute/server.rb +42 -43
- data/lib/fog/aliyun/models/compute/servers.rb +9 -11
- data/lib/fog/aliyun/models/compute/snapshot.rb +15 -15
- data/lib/fog/aliyun/models/compute/snapshots.rb +6 -10
- data/lib/fog/aliyun/models/compute/volume.rb +36 -40
- data/lib/fog/aliyun/models/compute/volumes.rb +7 -11
- data/lib/fog/aliyun/models/compute/vpc.rb +18 -19
- data/lib/fog/aliyun/models/compute/vpcs.rb +5 -6
- data/lib/fog/aliyun/models/compute/vrouter.rb +13 -13
- data/lib/fog/aliyun/models/compute/vrouters.rb +4 -5
- data/lib/fog/aliyun/models/compute/vswitch.rb +18 -20
- data/lib/fog/aliyun/models/compute/vswitches.rb +6 -6
- data/lib/fog/aliyun/models/storage/directories.rb +10 -16
- data/lib/fog/aliyun/models/storage/directory.rb +8 -8
- data/lib/fog/aliyun/models/storage/file.rb +58 -64
- data/lib/fog/aliyun/models/storage/files.rb +95 -115
- data/lib/fog/aliyun/requests/compute/allocate_eip_address.rb +18 -44
- data/lib/fog/aliyun/requests/compute/allocate_public_ip_address.rb +12 -36
- data/lib/fog/aliyun/requests/compute/associate_eip_address.rb +16 -40
- data/lib/fog/aliyun/requests/compute/attach_disk.rb +19 -22
- data/lib/fog/aliyun/requests/compute/create_disk.rb +33 -63
- data/lib/fog/aliyun/requests/compute/create_image.rb +21 -21
- data/lib/fog/aliyun/requests/compute/create_security_group.rb +16 -16
- data/lib/fog/aliyun/requests/compute/create_security_group_egress_ip_rule.rb +22 -63
- data/lib/fog/aliyun/requests/compute/create_security_group_egress_sg_rule.rb +23 -61
- data/lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb +22 -63
- data/lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb +23 -61
- data/lib/fog/aliyun/requests/compute/create_server.rb +76 -78
- data/lib/fog/aliyun/requests/compute/create_snapshot.rb +12 -26
- data/lib/fog/aliyun/requests/compute/create_vpc.rb +11 -38
- data/lib/fog/aliyun/requests/compute/create_vswitch.rb +13 -40
- data/lib/fog/aliyun/requests/compute/delete_disk.rb +8 -35
- data/lib/fog/aliyun/requests/compute/delete_image.rb +6 -33
- data/lib/fog/aliyun/requests/compute/delete_security_group.rb +13 -13
- data/lib/fog/aliyun/requests/compute/delete_security_group_egress_ip_rule.rb +22 -63
- data/lib/fog/aliyun/requests/compute/delete_security_group_egress_sg_rule.rb +23 -61
- data/lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb +22 -62
- data/lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb +23 -61
- data/lib/fog/aliyun/requests/compute/delete_server.rb +15 -15
- data/lib/fog/aliyun/requests/compute/delete_snapshot.rb +6 -20
- data/lib/fog/aliyun/requests/compute/delete_vpc.rb +9 -26
- data/lib/fog/aliyun/requests/compute/delete_vswitch.rb +9 -25
- data/lib/fog/aliyun/requests/compute/detach_disk.rb +11 -27
- data/lib/fog/aliyun/requests/compute/join_security_group.rb +15 -16
- data/lib/fog/aliyun/requests/compute/leave_security_group.rb +15 -16
- data/lib/fog/aliyun/requests/compute/list_disks.rb +24 -43
- data/lib/fog/aliyun/requests/compute/list_eip_addresses.rb +26 -52
- data/lib/fog/aliyun/requests/compute/list_images.rb +21 -24
- data/lib/fog/aliyun/requests/compute/list_route_tables.rb +16 -19
- data/lib/fog/aliyun/requests/compute/list_security_group_rules.rb +22 -23
- data/lib/fog/aliyun/requests/compute/list_security_groups.rb +21 -24
- data/lib/fog/aliyun/requests/compute/list_server_types.rb +50 -50
- data/lib/fog/aliyun/requests/compute/list_servers.rb +25 -28
- data/lib/fog/aliyun/requests/compute/list_snapshots.rb +20 -37
- data/lib/fog/aliyun/requests/compute/list_vpcs.rb +12 -29
- data/lib/fog/aliyun/requests/compute/list_vrouters.rb +13 -16
- data/lib/fog/aliyun/requests/compute/list_vswitchs.rb +14 -31
- data/lib/fog/aliyun/requests/compute/list_zones.rb +16 -16
- data/lib/fog/aliyun/requests/compute/modify_vpc.rb +17 -17
- data/lib/fog/aliyun/requests/compute/modify_vswitch.rb +11 -39
- data/lib/fog/aliyun/requests/compute/reboot_server.rb +15 -16
- data/lib/fog/aliyun/requests/compute/release_eip_address.rb +12 -36
- data/lib/fog/aliyun/requests/compute/start_server.rb +14 -15
- data/lib/fog/aliyun/requests/compute/stop_server.rb +13 -14
- data/lib/fog/aliyun/requests/compute/unassociate_eip_address.rb +16 -41
- data/lib/fog/aliyun/requests/storage/copy_object.rb +11 -14
- data/lib/fog/aliyun/requests/storage/delete_bucket.rb +30 -30
- data/lib/fog/aliyun/requests/storage/delete_container.rb +11 -14
- data/lib/fog/aliyun/requests/storage/delete_object.rb +20 -22
- data/lib/fog/aliyun/requests/storage/get_bucket.rb +141 -148
- data/lib/fog/aliyun/requests/storage/get_container.rb +26 -38
- data/lib/fog/aliyun/requests/storage/get_containers.rb +20 -32
- data/lib/fog/aliyun/requests/storage/get_object.rb +12 -12
- data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +11 -11
- data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +11 -11
- data/lib/fog/aliyun/requests/storage/head_object.rb +11 -11
- data/lib/fog/aliyun/requests/storage/list_buckets.rb +40 -47
- data/lib/fog/aliyun/requests/storage/list_objects.rb +91 -104
- data/lib/fog/aliyun/requests/storage/put_bucket.rb +22 -23
- data/lib/fog/aliyun/requests/storage/put_container.rb +12 -12
- data/lib/fog/aliyun/requests/storage/put_object.rb +100 -110
- data/lib/fog/aliyun/storage.rb +209 -214
- data/lib/fog/aliyun/version.rb +1 -1
- data/lib/fog/bin/aliyun.rb +5 -5
- metadata +55 -4
@@ -3,7 +3,7 @@ module Fog
|
|
3
3
|
class Aliyun
|
4
4
|
class Real
|
5
5
|
def get_container(container, options = {})
|
6
|
-
options = options.reject {|
|
6
|
+
options = options.reject { |_key, value| value.nil? }
|
7
7
|
|
8
8
|
bucket = options[:bucket]
|
9
9
|
bucket ||= @aliyun_oss_bucket
|
@@ -12,57 +12,45 @@ module Fog
|
|
12
12
|
maxKeys = options[:maxKeys]
|
13
13
|
delimiter = '/'
|
14
14
|
|
15
|
-
path =
|
15
|
+
path = ''
|
16
16
|
|
17
|
-
if container ==
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
prefix = if container == '' || container == '.' || container.nil?
|
18
|
+
nil
|
19
|
+
else
|
20
|
+
container + '/'
|
21
|
+
end
|
22
22
|
|
23
23
|
if prefix
|
24
|
-
path+=
|
25
|
-
if marker
|
26
|
-
|
27
|
-
|
28
|
-
if maxKeys
|
29
|
-
path+="&max-keys="+maxKeys
|
30
|
-
end
|
31
|
-
if delimiter
|
32
|
-
path+="&delimiter="+delimiter
|
33
|
-
end
|
24
|
+
path += '?prefix=' + prefix
|
25
|
+
path += '&marker=' + marker if marker
|
26
|
+
path += '&max-keys=' + maxKeys if maxKeys
|
27
|
+
path += '&delimiter=' + delimiter if delimiter
|
34
28
|
elsif marker
|
35
|
-
path+=
|
36
|
-
if maxKeys
|
37
|
-
|
38
|
-
end
|
39
|
-
if delimiter
|
40
|
-
path+="&delimiter="+delimiter
|
41
|
-
end
|
29
|
+
path += '?marker=' + marker
|
30
|
+
path += '&max-keys=' + maxKeys if maxKeys
|
31
|
+
path += '&delimiter=' + delimiter if delimiter
|
42
32
|
elsif maxKeys
|
43
|
-
path+=
|
44
|
-
if delimiter
|
45
|
-
path+="&delimiter="+delimiter
|
46
|
-
end
|
33
|
+
path += '?max-keys=' + maxKeys
|
34
|
+
path += '&delimiter=' + delimiter if delimiter
|
47
35
|
elsif delimiter
|
48
|
-
path+=
|
36
|
+
path += '?delimiter=' + delimiter
|
49
37
|
end
|
50
38
|
|
51
39
|
location = get_bucket_location(bucket)
|
52
|
-
endpoint =
|
53
|
-
resource = bucket+'/'
|
40
|
+
endpoint = 'http://' + location + '.aliyuncs.com'
|
41
|
+
resource = bucket + '/'
|
54
42
|
ret = request(
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
43
|
+
expects: [200, 203, 400],
|
44
|
+
method: 'GET',
|
45
|
+
path: path,
|
46
|
+
resource: resource,
|
47
|
+
bucket: bucket
|
60
48
|
)
|
61
49
|
xml = ret.data[:body]
|
62
|
-
result = XmlSimple.xml_in(xml)[
|
50
|
+
result = XmlSimple.xml_in(xml)['CommonPrefixes']
|
63
51
|
end
|
64
52
|
end
|
65
|
-
|
53
|
+
|
66
54
|
class Mock
|
67
55
|
def get_container(container, options = {})
|
68
56
|
end
|
@@ -12,7 +12,7 @@ module Fog
|
|
12
12
|
# ==== Returns
|
13
13
|
#
|
14
14
|
def get_containers(options = {})
|
15
|
-
options = options.reject {|
|
15
|
+
options = options.reject { |_key, value| value.nil? }
|
16
16
|
bucket = options[:bucket]
|
17
17
|
bucket ||= @aliyun_oss_bucket
|
18
18
|
prefix = options[:prefix]
|
@@ -20,50 +20,38 @@ module Fog
|
|
20
20
|
maxKeys = options[:maxKeys]
|
21
21
|
delimiter = '/'
|
22
22
|
|
23
|
-
path =
|
23
|
+
path = ''
|
24
24
|
if prefix
|
25
|
-
path+=
|
26
|
-
if marker
|
27
|
-
|
28
|
-
|
29
|
-
if maxKeys
|
30
|
-
path+="&max-keys="+maxKeys
|
31
|
-
end
|
32
|
-
if delimiter
|
33
|
-
path+="&delimiter="+delimiter
|
34
|
-
end
|
25
|
+
path += '?prefix=' + prefix
|
26
|
+
path += '&marker=' + marker if marker
|
27
|
+
path += '&max-keys=' + maxKeys if maxKeys
|
28
|
+
path += '&delimiter=' + delimiter if delimiter
|
35
29
|
|
36
30
|
elsif marker
|
37
|
-
path+=
|
38
|
-
if maxKeys
|
39
|
-
|
40
|
-
end
|
41
|
-
if delimiter
|
42
|
-
path+="&delimiter="+delimiter
|
43
|
-
end
|
31
|
+
path += '?marker=' + marker
|
32
|
+
path += '&max-keys=' + maxKeys if maxKeys
|
33
|
+
path += '&delimiter=' + delimiter if delimiter
|
44
34
|
|
45
35
|
elsif maxKeys
|
46
|
-
path+=
|
47
|
-
if delimiter
|
48
|
-
path+="&delimiter="+delimiter
|
49
|
-
end
|
36
|
+
path += '?max-keys=' + maxKeys
|
37
|
+
path += '&delimiter=' + delimiter if delimiter
|
50
38
|
|
51
39
|
elsif delimiter
|
52
|
-
path+=
|
40
|
+
path += '?delimiter=' + delimiter
|
53
41
|
end
|
54
42
|
|
55
43
|
location = get_bucket_location(bucket)
|
56
|
-
endpoint =
|
57
|
-
resource = bucket+'/'
|
44
|
+
endpoint = 'http://' + location + '.aliyuncs.com'
|
45
|
+
resource = bucket + '/'
|
58
46
|
ret = request(
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
47
|
+
expects: [200, 203, 400],
|
48
|
+
method: 'GET',
|
49
|
+
path: path,
|
50
|
+
resource: resource,
|
51
|
+
bucket: bucket
|
64
52
|
)
|
65
53
|
xml = ret.data[:body]
|
66
|
-
result = XmlSimple.xml_in(xml)[
|
54
|
+
result = XmlSimple.xml_in(xml)['CommonPrefixes']
|
67
55
|
end
|
68
56
|
end
|
69
57
|
|
@@ -8,27 +8,27 @@ module Fog
|
|
8
8
|
# * object<~String> - Name of object to look for
|
9
9
|
#
|
10
10
|
def get_object(object, range = nil, options = {})
|
11
|
-
options = options.reject {|
|
11
|
+
options = options.reject { |_key, value| value.nil? }
|
12
12
|
bucket = options[:bucket]
|
13
13
|
bucket ||= @aliyun_oss_bucket
|
14
14
|
endpoint = options[:endpoint]
|
15
|
-
if
|
15
|
+
if nil == endpoint
|
16
16
|
location = get_bucket_location(bucket)
|
17
|
-
endpoint =
|
17
|
+
endpoint = 'http://' + location + '.aliyuncs.com'
|
18
18
|
end
|
19
|
-
resource = bucket+'/'+object
|
19
|
+
resource = bucket + '/' + object
|
20
20
|
para = {
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
21
|
+
expects: [200, 206, 404],
|
22
|
+
method: 'GET',
|
23
|
+
path: object,
|
24
|
+
bucket: bucket,
|
25
|
+
resource: resource,
|
26
|
+
endpoint: endpoint
|
27
27
|
}
|
28
28
|
|
29
29
|
if range
|
30
|
-
rangeStr =
|
31
|
-
para[:headers] = {'Range' => rangeStr}
|
30
|
+
rangeStr = 'bytes=' + range
|
31
|
+
para[:headers] = { 'Range' => rangeStr }
|
32
32
|
end
|
33
33
|
|
34
34
|
response = request(para)
|
@@ -13,23 +13,23 @@ module Fog
|
|
13
13
|
# * response<~Excon::Response>:
|
14
14
|
# * body<~String> - url for object
|
15
15
|
def get_object_http_url_public(object, expires, options = {})
|
16
|
-
options = options.reject {|
|
16
|
+
options = options.reject { |_key, value| value.nil? }
|
17
17
|
bucket = options[:bucket]
|
18
18
|
bucket ||= @aliyun_oss_bucket
|
19
19
|
acl = get_bucket_acl(bucket)
|
20
20
|
location = get_bucket_location(bucket)
|
21
|
-
|
22
|
-
if
|
21
|
+
|
22
|
+
if 'private' == acl
|
23
23
|
expires_time = (Time.now.to_i + expires).to_s
|
24
|
-
resource = bucket+'/'+object
|
25
|
-
signature = sign(
|
26
|
-
url =
|
27
|
-
|
28
|
-
|
29
|
-
elsif
|
30
|
-
url =
|
24
|
+
resource = bucket + '/' + object
|
25
|
+
signature = sign('GET', expires_time, nil, resource)
|
26
|
+
url = 'http://' + bucket + '.' + location + '.aliyuncs.com/' + object +
|
27
|
+
'?OSSAccessKeyId=' + @aliyun_accesskey_id + '&Expires=' + expires_time +
|
28
|
+
'&Signature=' + URI.encode(signature, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
29
|
+
elsif 'public-read' == acl || 'public-read-write' == acl
|
30
|
+
url = 'http://' + bucket + '.' + location + '.aliyuncs.com/' + object
|
31
31
|
else
|
32
|
-
url =
|
32
|
+
url = 'acl is wrong with value:' + acl
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -13,23 +13,23 @@ module Fog
|
|
13
13
|
# * response<~Excon::Response>:
|
14
14
|
# * body<~String> - url for object
|
15
15
|
def get_object_https_url_public(object, expires, options = {})
|
16
|
-
options = options.reject {|
|
16
|
+
options = options.reject { |_key, value| value.nil? }
|
17
17
|
bucket = options[:bucket]
|
18
18
|
bucket ||= @aliyun_oss_bucket
|
19
19
|
acl = get_bucket_acl(bucket)
|
20
20
|
location = get_bucket_location(bucket)
|
21
|
-
|
22
|
-
if
|
21
|
+
|
22
|
+
if 'private' == acl
|
23
23
|
expires_time = (Time.now.to_i + expires).to_s
|
24
|
-
resource = bucket+'/'+object
|
25
|
-
signature = sign(
|
26
|
-
url =
|
27
|
-
|
28
|
-
|
29
|
-
elsif
|
30
|
-
url =
|
24
|
+
resource = bucket + '/' + object
|
25
|
+
signature = sign('GET', expires_time, nil, resource)
|
26
|
+
url = 'https://' + bucket + '.' + location + '.aliyuncs.com/' + object +
|
27
|
+
'?OSSAccessKeyId=' + @aliyun_accesskey_id + '&Expires=' + expires_time +
|
28
|
+
'&Signature=' + URI.encode(signature, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
29
|
+
elsif 'public-read' == acl || 'public-read-write' == acl
|
30
|
+
url = 'https://' + bucket + '.' + location + '.aliyuncs.com/' + object
|
31
31
|
else
|
32
|
-
url =
|
32
|
+
url = 'acl is wrong with value:' + acl
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -7,26 +7,26 @@ module Fog
|
|
7
7
|
# ==== Parameters
|
8
8
|
# * object<~String> - Name of object to look for
|
9
9
|
#
|
10
|
-
def head_object(object, options={})
|
10
|
+
def head_object(object, options = {})
|
11
11
|
bucket = options[:bucket]
|
12
12
|
bucket ||= @aliyun_oss_bucket
|
13
13
|
location = get_bucket_location(bucket)
|
14
|
-
endpoint =
|
15
|
-
resource = bucket+'/'+object
|
14
|
+
endpoint = 'http://' + location + '.aliyuncs.com'
|
15
|
+
resource = bucket + '/' + object
|
16
16
|
ret = request(
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
17
|
+
expects: [200, 404],
|
18
|
+
method: 'HEAD',
|
19
|
+
path: object,
|
20
|
+
bucket: bucket,
|
21
|
+
resource: resource,
|
22
|
+
endpoint: endpoint
|
23
23
|
)
|
24
|
-
|
24
|
+
ret
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
class Mock
|
29
|
-
def head_object(object, options={})
|
29
|
+
def head_object(object, options = {})
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -1,47 +1,40 @@
|
|
1
|
-
module Fog
|
2
|
-
module Storage
|
3
|
-
class Aliyun
|
4
|
-
class Real
|
5
|
-
def list_buckets(options={})
|
6
|
-
prefix = options[:prefix]
|
7
|
-
marker = options[:marker]
|
8
|
-
maxKeys = options[:maxKeys]
|
9
|
-
|
10
|
-
path =
|
11
|
-
if prefix
|
12
|
-
path+=
|
13
|
-
if marker
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
elsif
|
21
|
-
path+=
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
path
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
class Mock
|
42
|
-
def list_buckets(options={})
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class Aliyun
|
4
|
+
class Real
|
5
|
+
def list_buckets(options = {})
|
6
|
+
prefix = options[:prefix]
|
7
|
+
marker = options[:marker]
|
8
|
+
maxKeys = options[:maxKeys]
|
9
|
+
|
10
|
+
path = ''
|
11
|
+
if prefix
|
12
|
+
path += '?prefix=' + prefix
|
13
|
+
path += '&marker=' + marker if marker
|
14
|
+
path += '&max-keys=' + maxKeys if maxKeys
|
15
|
+
|
16
|
+
elsif marker
|
17
|
+
path += '?marker=' + marker
|
18
|
+
path += '&max-keys=' + maxKeys if maxKeys
|
19
|
+
|
20
|
+
elsif maxKeys
|
21
|
+
path += '?max-keys=' + maxKeys
|
22
|
+
end
|
23
|
+
|
24
|
+
ret = request(
|
25
|
+
expects: [200, 203],
|
26
|
+
method: 'GET',
|
27
|
+
path: path
|
28
|
+
)
|
29
|
+
xml = ret.data[:body]
|
30
|
+
result = XmlSimple.xml_in(xml)['Buckets'][0]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Mock
|
35
|
+
def list_buckets(options = {})
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -1,104 +1,91 @@
|
|
1
|
-
module Fog
|
2
|
-
module Storage
|
3
|
-
class Aliyun
|
4
|
-
class Real
|
5
|
-
def list_objects(options={})
|
6
|
-
bucket = options[:bucket]
|
7
|
-
bucket ||= @aliyun_oss_bucket
|
8
|
-
prefix = options[:prefix]
|
9
|
-
marker = options[:marker]
|
10
|
-
maxKeys = options[:maxKeys]
|
11
|
-
delimiter = options[:delimiter]
|
12
|
-
|
13
|
-
path =
|
14
|
-
if prefix
|
15
|
-
path+=
|
16
|
-
if marker
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
if
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
path+=
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
)
|
93
|
-
parts = XmlSimple.xml_in(ret.data[:body])["Part"]
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
|
-
class Mock
|
99
|
-
def list_objects(options={})
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class Aliyun
|
4
|
+
class Real
|
5
|
+
def list_objects(options = {})
|
6
|
+
bucket = options[:bucket]
|
7
|
+
bucket ||= @aliyun_oss_bucket
|
8
|
+
prefix = options[:prefix]
|
9
|
+
marker = options[:marker]
|
10
|
+
maxKeys = options[:maxKeys]
|
11
|
+
delimiter = options[:delimiter]
|
12
|
+
|
13
|
+
path = ''
|
14
|
+
if prefix
|
15
|
+
path += '?prefix=' + prefix
|
16
|
+
path += '&marker=' + marker if marker
|
17
|
+
path += '&max-keys=' + maxKeys if maxKeys
|
18
|
+
path += '&delimiter=' + delimiter if delimiter
|
19
|
+
|
20
|
+
elsif marker
|
21
|
+
path += '?marker=' + marker
|
22
|
+
path += '&max-keys=' + maxKeys if maxKeys
|
23
|
+
path += '&delimiter=' + delimiter if delimiter
|
24
|
+
|
25
|
+
elsif maxKeys
|
26
|
+
path += '?max-keys=' + maxKeys
|
27
|
+
path += '&delimiter=' + delimiter if delimiter
|
28
|
+
elsif delimiter
|
29
|
+
path += '?delimiter=' + delimiter
|
30
|
+
end
|
31
|
+
|
32
|
+
location = get_bucket_location(bucket)
|
33
|
+
endpoint = 'http://' + location + '.aliyuncs.com'
|
34
|
+
resource = bucket + '/'
|
35
|
+
ret = request(
|
36
|
+
expects: [200, 203, 400],
|
37
|
+
method: 'GET',
|
38
|
+
path: path,
|
39
|
+
resource: resource,
|
40
|
+
bucket: bucket
|
41
|
+
)
|
42
|
+
xml = ret.data[:body]
|
43
|
+
result = XmlSimple.xml_in(xml)
|
44
|
+
end
|
45
|
+
|
46
|
+
def list_multipart_uploads(bucket, endpoint, _options = {})
|
47
|
+
if nil == endpoint
|
48
|
+
location = get_bucket_location(bucket)
|
49
|
+
endpoint = 'http://' + location + '.aliyuncs.com'
|
50
|
+
end
|
51
|
+
path = '?uploads'
|
52
|
+
resource = bucket + '/' + path
|
53
|
+
|
54
|
+
ret = request(
|
55
|
+
expects: 200,
|
56
|
+
method: 'GET',
|
57
|
+
path: path,
|
58
|
+
bucket: bucket,
|
59
|
+
resource: resource,
|
60
|
+
endpoint: endpoint
|
61
|
+
)
|
62
|
+
uploadid = XmlSimple.xml_in(ret.data[:body])['Upload']
|
63
|
+
end
|
64
|
+
|
65
|
+
def list_parts(bucket, object, endpoint, uploadid, _options = {})
|
66
|
+
if nil == endpoint
|
67
|
+
location = get_bucket_location(bucket)
|
68
|
+
endpoint = 'http://' + location + '.aliyuncs.com'
|
69
|
+
end
|
70
|
+
path = object + '?uploadId=' + uploadid
|
71
|
+
resource = bucket + '/' + path
|
72
|
+
|
73
|
+
ret = request(
|
74
|
+
expects: 200,
|
75
|
+
method: 'GET',
|
76
|
+
path: path,
|
77
|
+
bucket: bucket,
|
78
|
+
resource: resource,
|
79
|
+
endpoint: endpoint
|
80
|
+
)
|
81
|
+
parts = XmlSimple.xml_in(ret.data[:body])['Part']
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
class Mock
|
86
|
+
def list_objects(options = {})
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|