fog-aliyun 0.3.17 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +35 -2
- data/fog-aliyun.gemspec +4 -3
- data/lib/fog/aliyun/compute.rb +7 -5
- data/lib/fog/aliyun/models/storage/directories.rb +30 -53
- data/lib/fog/aliyun/models/storage/directory.rb +96 -17
- data/lib/fog/aliyun/models/storage/file.rb +127 -126
- data/lib/fog/aliyun/models/storage/files.rb +43 -124
- data/lib/fog/aliyun/requests/compute/attach_disk.rb +3 -1
- data/lib/fog/aliyun/requests/compute/create_security_group_egress_ip_rule.rb +4 -2
- data/lib/fog/aliyun/requests/compute/create_security_group_egress_sg_rule.rb +3 -1
- data/lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb +4 -2
- data/lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb +3 -1
- data/lib/fog/aliyun/requests/compute/create_vpc.rb +3 -1
- data/lib/fog/aliyun/requests/compute/create_vswitch.rb +3 -1
- data/lib/fog/aliyun/requests/compute/delete_security_group_egress_ip_rule.rb +4 -2
- data/lib/fog/aliyun/requests/compute/delete_security_group_egress_sg_rule.rb +3 -1
- data/lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb +4 -2
- data/lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb +3 -1
- data/lib/fog/aliyun/requests/compute/detach_disk.rb +3 -1
- data/lib/fog/aliyun/requests/compute/modify_vpc.rb +3 -1
- data/lib/fog/aliyun/requests/compute/modify_vswitch.rb +3 -1
- data/lib/fog/aliyun/requests/storage/abort_multipart_upload.rb +22 -0
- data/lib/fog/aliyun/requests/storage/complete_multipart_upload.rb +21 -0
- data/lib/fog/aliyun/requests/storage/copy_object.rb +14 -18
- data/lib/fog/aliyun/requests/storage/delete_bucket.rb +3 -9
- data/lib/fog/aliyun/requests/storage/delete_multiple_objects.rb +20 -0
- data/lib/fog/aliyun/requests/storage/delete_object.rb +10 -11
- data/lib/fog/aliyun/requests/storage/get_bucket.rb +22 -99
- data/lib/fog/aliyun/requests/storage/get_bucket_location.rb +33 -0
- data/lib/fog/aliyun/requests/storage/get_object.rb +20 -12
- data/lib/fog/aliyun/requests/storage/get_object_acl.rb +30 -0
- data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +9 -10
- data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +9 -10
- data/lib/fog/aliyun/requests/storage/get_service.rb +13 -0
- data/lib/fog/aliyun/requests/storage/head_object.rb +25 -13
- data/lib/fog/aliyun/requests/storage/initiate_multipart_upload.rb +19 -0
- data/lib/fog/aliyun/requests/storage/list_buckets.rb +5 -25
- data/lib/fog/aliyun/requests/storage/list_objects.rb +10 -62
- data/lib/fog/aliyun/requests/storage/put_bucket.rb +2 -8
- data/lib/fog/aliyun/requests/storage/put_object.rb +16 -122
- data/lib/fog/aliyun/requests/storage/upload_part.rb +24 -0
- data/lib/fog/aliyun/storage.rb +20 -4
- data/lib/fog/aliyun/version.rb +1 -1
- metadata +31 -19
- data/lib/fog/aliyun/requests/storage/delete_container.rb +0 -30
- data/lib/fog/aliyun/requests/storage/get_container.rb +0 -57
- data/lib/fog/aliyun/requests/storage/get_containers.rb +0 -61
- data/lib/fog/aliyun/requests/storage/put_container.rb +0 -29
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'addressable'
|
4
|
+
|
3
5
|
module Fog
|
4
6
|
module Aliyun
|
5
7
|
class Storage
|
@@ -7,29 +9,26 @@ module Fog
|
|
7
9
|
# Get an expiring object https url from Cloud Files
|
8
10
|
#
|
9
11
|
# ==== Parameters
|
10
|
-
# *
|
11
|
-
# *
|
12
|
+
# * bucket_name<~String> - Name of bucket
|
13
|
+
# * object_name<~String> - Name of object to get expiring url for
|
12
14
|
# * expires<~Integer> - An expiry time for this url
|
13
15
|
#
|
14
16
|
# ==== Returns
|
15
17
|
# * response<~Excon::Response>:
|
16
18
|
# * body<~String> - url for object
|
17
|
-
def get_object_https_url_public(
|
18
|
-
options = options.reject { |_key, value| value.nil? }
|
19
|
-
bucket_name = options[:bucket]
|
20
|
-
bucket_name ||= @aliyun_oss_bucket
|
19
|
+
def get_object_https_url_public(bucket_name, object_name, expires)
|
21
20
|
bucket = @oss_client.get_bucket(bucket_name)
|
22
21
|
acl = bucket.acl()
|
23
22
|
|
24
23
|
if acl == 'private'
|
25
24
|
expires_time = (Time.now.to_i + (expires.nil? ? 0 : expires.to_i)).to_s
|
26
|
-
resource = bucket_name + '/' +
|
25
|
+
resource = bucket_name + '/' + object_name
|
27
26
|
signature = sign('GET', expires_time, nil, resource)
|
28
|
-
'https://' + bucket_name + '.' + @host + '/' +
|
27
|
+
'https://' + bucket_name + '.' + @host + '/' + object_name +
|
29
28
|
'?OSSAccessKeyId=' + @aliyun_accesskey_id + '&Expires=' + expires_time +
|
30
|
-
'&Signature=' + URI.
|
29
|
+
'&Signature=' + Addressable::URI.encode_component(signature, Addressable::URI::CharacterClasses::UNRESERVED + '|')
|
31
30
|
elsif acl == 'public-read' || acl == 'public-read-write'
|
32
|
-
'https://' + bucket_name + '.' + @host + '/' +
|
31
|
+
'https://' + bucket_name + '.' + @host + '/' + object_name
|
33
32
|
else
|
34
33
|
'acl is wrong with value:' + acl
|
35
34
|
end
|
@@ -7,20 +7,32 @@ module Fog
|
|
7
7
|
# Get headers for object
|
8
8
|
#
|
9
9
|
# ==== Parameters
|
10
|
-
# *
|
10
|
+
# * object_name<~String> - Name of object to look for
|
11
11
|
#
|
12
|
-
def head_object(
|
13
|
-
bucket_name
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
def head_object(bucket_name, object_name, options={})
|
13
|
+
unless bucket_name
|
14
|
+
raise ArgumentError.new('bucket_name is required')
|
15
|
+
end
|
16
|
+
unless object_name
|
17
|
+
raise ArgumentError.new('object_name is required')
|
18
|
+
end
|
19
|
+
|
20
|
+
# Currently, the ruby sdk does not support versionId
|
21
|
+
# if version_id = options.delete('versionId')
|
22
|
+
# query = {'versionId' => version_id}
|
23
|
+
# end
|
24
|
+
headers = {}
|
25
|
+
headers['If-Modified-Since'] = Fog::Time.at(options['If-Modified-Since'].to_i).to_date_header if options['If-Modified-Since']
|
26
|
+
headers['If-Unmodified-Since'] = Fog::Time.at(options['If-Unmodified-Since'].to_i).to_date_header if options['If-Modified-Since']
|
27
|
+
headers.merge!(options)
|
28
|
+
resources = {
|
29
|
+
:bucket => bucket_name,
|
30
|
+
:object => object_name
|
31
|
+
}
|
32
|
+
http_options = {
|
33
|
+
:headers => headers
|
34
|
+
}
|
35
|
+
@oss_http.head(resources, http_options)
|
24
36
|
end
|
25
37
|
end
|
26
38
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Aliyun
|
3
|
+
class Storage
|
4
|
+
class Real
|
5
|
+
# Initiate a multipart upload
|
6
|
+
#
|
7
|
+
# @param bucket_name [String] Name of bucket to create
|
8
|
+
# @param object_name [String] Name of object to create
|
9
|
+
# @param options [Hash]
|
10
|
+
#
|
11
|
+
# @see https://help.aliyun.com/document_detail/31992.html
|
12
|
+
#
|
13
|
+
def initiate_multipart_upload(bucket_name, object_name, options = {})
|
14
|
+
@oss_protocol.initiate_multipart_upload(bucket_name, object_name, options)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -5,33 +5,13 @@ module Fog
|
|
5
5
|
class Storage
|
6
6
|
class Real
|
7
7
|
def list_buckets(options = {})
|
8
|
-
|
9
|
-
marker = options[:marker]
|
10
|
-
maxKeys = options[:maxKeys] || 1000
|
8
|
+
maxKeys = options[:max_keys] || 1000
|
11
9
|
maxKeys = maxKeys.to_i
|
12
|
-
maxKeys =[maxKeys,1000].min
|
10
|
+
maxKeys = [maxKeys, 1000].min
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
path += '&marker=' + marker if marker
|
18
|
-
path += '&max-keys=' + maxKeys if maxKeys
|
19
|
-
|
20
|
-
elsif marker
|
21
|
-
path += '?marker=' + marker
|
22
|
-
path += '&max-keys=' + maxKeys if maxKeys
|
23
|
-
|
24
|
-
elsif maxKeys
|
25
|
-
path += '?max-keys=' + maxKeys
|
26
|
-
end
|
27
|
-
|
28
|
-
ret = request(
|
29
|
-
expects: [200, 203],
|
30
|
-
method: 'GET',
|
31
|
-
path: path
|
32
|
-
)
|
33
|
-
xml = ret.data[:body]
|
34
|
-
XmlSimple.xml_in(xml)['Buckets'][0]
|
12
|
+
options[:limit] = maxKeys
|
13
|
+
options.delete(:max_keys)
|
14
|
+
@oss_protocol.list_buckets(options)
|
35
15
|
end
|
36
16
|
end
|
37
17
|
end
|
@@ -4,74 +4,22 @@ module Fog
|
|
4
4
|
module Aliyun
|
5
5
|
class Storage
|
6
6
|
class Real
|
7
|
-
def list_objects(options = {})
|
8
|
-
|
9
|
-
bucket ||= @aliyun_oss_bucket
|
10
|
-
prefix = options['prefix']
|
11
|
-
marker = options['marker']
|
12
|
-
# Set the ListObjects max limitation to 1000
|
13
|
-
maxKeys = options[:maxKeys]||1000
|
7
|
+
def list_objects(bucket_name, options = {})
|
8
|
+
maxKeys = options[:max_keys] || 1000
|
14
9
|
maxKeys = maxKeys.to_i
|
15
|
-
maxKeys = [maxKeys,1000].min
|
16
|
-
delimiter = options['delimiter']
|
10
|
+
maxKeys = [maxKeys, 1000].min
|
17
11
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
path += '&marker=' + marker if marker
|
22
|
-
path += '&max-keys=' + maxKeys if maxKeys
|
23
|
-
path += '&delimiter=' + delimiter if delimiter
|
24
|
-
|
25
|
-
elsif marker
|
26
|
-
path += '/?marker=' + marker
|
27
|
-
path += '&max-keys=' + maxKeys if maxKeys
|
28
|
-
path += '&delimiter=' + delimiter if delimiter
|
29
|
-
|
30
|
-
elsif maxKeys
|
31
|
-
path += '/?max-keys=' + maxKeys
|
32
|
-
path += '&delimiter=' + delimiter if delimiter
|
33
|
-
elsif delimiter
|
34
|
-
path += '/?delimiter=' + delimiter
|
35
|
-
end
|
36
|
-
|
37
|
-
resource = bucket + '/'
|
38
|
-
ret = request(
|
39
|
-
expects: [200, 203, 400],
|
40
|
-
method: 'GET',
|
41
|
-
path: path,
|
42
|
-
resource: resource,
|
43
|
-
bucket: bucket
|
44
|
-
)
|
45
|
-
xml = ret.data[:body]
|
46
|
-
XmlSimple.xml_in(xml)
|
12
|
+
options[:limit] = maxKeys
|
13
|
+
options.delete(:max_keys)
|
14
|
+
@oss_protocol.list_objects(bucket_name, options)
|
47
15
|
end
|
48
16
|
|
49
|
-
def list_multipart_uploads(
|
50
|
-
|
51
|
-
resource = bucket + '/' + path
|
52
|
-
|
53
|
-
ret = request(
|
54
|
-
expects: 200,
|
55
|
-
method: 'GET',
|
56
|
-
path: path,
|
57
|
-
bucket: bucket,
|
58
|
-
resource: resource
|
59
|
-
)
|
60
|
-
XmlSimple.xml_in(ret.data[:body])['Upload']
|
17
|
+
def list_multipart_uploads(bucket_name, _options = {})
|
18
|
+
@oss_protocol.list_multipart_uploads(bucket_name, _options)
|
61
19
|
end
|
62
20
|
|
63
|
-
def list_parts(
|
64
|
-
|
65
|
-
resource = bucket + '/' + path
|
66
|
-
|
67
|
-
ret = request(
|
68
|
-
expects: 200,
|
69
|
-
method: 'GET',
|
70
|
-
path: path,
|
71
|
-
bucket: bucket,
|
72
|
-
resource: resource
|
73
|
-
)
|
74
|
-
XmlSimple.xml_in(ret.data[:body])['Part']
|
21
|
+
def list_parts(bucket_name, object_name, upload_id, _options = {})
|
22
|
+
@oss_protocol.list_parts(bucket_name, object_name, upload_id, _options)
|
75
23
|
end
|
76
24
|
end
|
77
25
|
end
|
@@ -4,14 +4,8 @@ module Fog
|
|
4
4
|
module Aliyun
|
5
5
|
class Storage
|
6
6
|
class Real
|
7
|
-
def put_bucket(
|
8
|
-
|
9
|
-
request(
|
10
|
-
expects: [200, 203],
|
11
|
-
method: 'PUT',
|
12
|
-
resource: resource,
|
13
|
-
bucket: bucketName
|
14
|
-
)
|
7
|
+
def put_bucket(bucket_name, options = {})
|
8
|
+
@oss_protocol.create_bucket(bucket_name, options)
|
15
9
|
end
|
16
10
|
end
|
17
11
|
end
|
@@ -7,133 +7,27 @@ module Fog
|
|
7
7
|
# Put details for object
|
8
8
|
#
|
9
9
|
# ==== Parameters
|
10
|
-
# *
|
10
|
+
# * bucket_name<~String> - Name of bucket to look for
|
11
|
+
# * object_name<~String> - Object of object to look for
|
12
|
+
# * data<~File>
|
13
|
+
# * options<~Hash>
|
11
14
|
#
|
12
|
-
def put_object(
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# With a single PUT operation you can upload objects up to 5 GB in size.
|
18
|
-
if file.size > 5_368_709_120
|
19
|
-
bucket.resumable_upload(object, file.path)
|
20
|
-
end
|
21
|
-
bucket.put_object(object, :file => file.path)
|
22
|
-
end
|
23
|
-
|
24
|
-
def put_object_with_body(object, body, options = {})
|
25
|
-
bucket_name = options[:bucket]
|
26
|
-
bucket_name ||= @aliyun_oss_bucket
|
27
|
-
|
28
|
-
resource = bucket_name + '/' + object
|
29
|
-
request(
|
30
|
-
expects: [200, 203],
|
31
|
-
method: 'PUT',
|
32
|
-
path: object,
|
33
|
-
bucket: bucket_name,
|
34
|
-
resource: resource,
|
35
|
-
body: body
|
36
|
-
)
|
37
|
-
end
|
38
|
-
|
39
|
-
def put_folder(bucket, folder)
|
40
|
-
path = folder + '/'
|
41
|
-
resource = bucket + '/' + folder + '/'
|
42
|
-
request(
|
43
|
-
expects: [200, 203],
|
44
|
-
method: 'PUT',
|
45
|
-
path: path,
|
46
|
-
bucket: bucket,
|
47
|
-
resource: resource
|
48
|
-
)
|
49
|
-
end
|
50
|
-
|
51
|
-
def put_multipart_object(bucket, object, file)
|
52
|
-
# find the right uploadid
|
53
|
-
uploads = list_multipart_uploads(bucket)
|
54
|
-
upload = (uploads&.find { |tmpupload| tmpupload['Key'][0] == object })
|
55
|
-
|
56
|
-
uploadedSize = 0
|
57
|
-
start_partNumber = 1
|
58
|
-
if !upload.nil?
|
59
|
-
uploadId = upload['UploadId'][0]
|
60
|
-
parts = list_parts(bucket, object, uploadId)
|
61
|
-
if !parts.nil? && !parts.empty?
|
62
|
-
if parts[-1]['Size'][0].to_i != 5_242_880
|
63
|
-
# the part is the last one, if its size is over 5m, then finish this upload
|
64
|
-
complete_multipart_upload(bucket, object, uploadId)
|
65
|
-
return
|
15
|
+
def put_object(bucket_name, object_name, data, options = {})
|
16
|
+
if data.is_a? ::File
|
17
|
+
@oss_protocol.put_object(bucket_name, object_name, options)do |sw|
|
18
|
+
while line = data.read(16*1024)
|
19
|
+
sw.write(line)
|
66
20
|
end
|
67
|
-
uploadedSize = (parts[0]['Size'][0].to_i * (parts.size - 1)) + parts[-1]['Size'][0].to_i
|
68
|
-
start_partNumber = parts[-1]['PartNumber'][0].to_i + 1
|
69
21
|
end
|
70
22
|
else
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
end_partNumber = (file.size + 5_242_880 - 1) / 5_242_880
|
81
|
-
file.seek(uploadedSize)
|
82
|
-
|
83
|
-
for i in start_partNumber..end_partNumber
|
84
|
-
body = file.read(5_242_880)
|
85
|
-
upload_part(bucket, object, i.to_s, uploadId, body)
|
86
|
-
end
|
87
|
-
|
88
|
-
complete_multipart_upload(bucket, object, uploadId)
|
89
|
-
end
|
90
|
-
|
91
|
-
def initiate_multipart_upload(bucket, object)
|
92
|
-
path = object + '?uploads'
|
93
|
-
resource = bucket + '/' + path
|
94
|
-
ret = request(
|
95
|
-
expects: 200,
|
96
|
-
method: 'POST',
|
97
|
-
path: path,
|
98
|
-
bucket: bucket,
|
99
|
-
resource: resource
|
100
|
-
)
|
101
|
-
XmlSimple.xml_in(ret.data[:body])['UploadId'][0]
|
102
|
-
end
|
103
|
-
|
104
|
-
def upload_part(bucket, object, partNumber, uploadId, body)
|
105
|
-
path = object + '?partNumber=' + partNumber + '&uploadId=' + uploadId
|
106
|
-
resource = bucket + '/' + path
|
107
|
-
request(
|
108
|
-
expects: [200, 203],
|
109
|
-
method: 'PUT',
|
110
|
-
path: path,
|
111
|
-
bucket: bucket,
|
112
|
-
resource: resource,
|
113
|
-
body: body
|
114
|
-
)
|
115
|
-
end
|
116
|
-
|
117
|
-
def complete_multipart_upload(bucket, object, uploadId)
|
118
|
-
parts = list_parts(bucket, object, uploadId, options = {})
|
119
|
-
request_part = []
|
120
|
-
return if parts.empty?
|
121
|
-
for i in 0..(parts.size - 1)
|
122
|
-
part = parts[i]
|
123
|
-
request_part[i] = { 'PartNumber' => part['PartNumber'], 'ETag' => part['ETag'] }
|
23
|
+
content=StringIO.new(data.dup)
|
24
|
+
@oss_protocol.put_object(bucket_name, object_name, options)do |sw|
|
25
|
+
while line=content.read(16*1024)
|
26
|
+
sw.write(line)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
content.close
|
124
30
|
end
|
125
|
-
body = XmlSimple.xml_out({ 'Part' => request_part }, 'RootName' => 'CompleteMultipartUpload')
|
126
|
-
|
127
|
-
path = object + '?uploadId=' + uploadId
|
128
|
-
resource = bucket + '/' + path
|
129
|
-
request(
|
130
|
-
expects: 200,
|
131
|
-
method: 'POST',
|
132
|
-
path: path,
|
133
|
-
bucket: bucket,
|
134
|
-
resource: resource,
|
135
|
-
body: body
|
136
|
-
)
|
137
31
|
end
|
138
32
|
end
|
139
33
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
module Fog
|
3
|
+
module Aliyun
|
4
|
+
class Storage
|
5
|
+
class Real
|
6
|
+
# Upload a part for a multipart upload
|
7
|
+
#
|
8
|
+
# @param bucket_name [String] Name of bucket to add part to
|
9
|
+
# @param object_name [String] Name of object to add part to
|
10
|
+
# @param upload_id [String] Id of upload to add part to
|
11
|
+
# @param part_number [String] Index of part in upload
|
12
|
+
# @param data [File||String] Content for part
|
13
|
+
#
|
14
|
+
# @see https://help.aliyun.com/document_detail/31993.html
|
15
|
+
#
|
16
|
+
def upload_part(bucket_name, object_name, upload_id, part_number, data)
|
17
|
+
@oss_protocol.upload_part(bucket_name, object_name, upload_id, part_number) do |sw|
|
18
|
+
sw.write(data)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/fog/aliyun/storage.rb
CHANGED
@@ -9,6 +9,7 @@ AliyunOssSdk= Aliyun::OSS
|
|
9
9
|
module Fog
|
10
10
|
module Aliyun
|
11
11
|
class Storage < Fog::Service
|
12
|
+
COMPLIANT_BUCKET_NAMES = /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
|
12
13
|
DEFAULT_REGION = 'cn-hangzhou'
|
13
14
|
|
14
15
|
DEFAULT_SCHEME = 'https'
|
@@ -36,19 +37,23 @@ module Fog
|
|
36
37
|
request :copy_object
|
37
38
|
request :delete_bucket
|
38
39
|
request :delete_object
|
40
|
+
request :delete_multiple_objects
|
39
41
|
request :get_bucket
|
42
|
+
request :get_bucket_location
|
40
43
|
request :get_object
|
44
|
+
request :get_object_acl
|
41
45
|
request :get_object_http_url
|
42
46
|
request :get_object_https_url
|
43
47
|
request :head_object
|
44
48
|
request :put_bucket
|
45
49
|
request :put_object
|
50
|
+
request :get_service
|
46
51
|
request :list_buckets
|
47
52
|
request :list_objects
|
48
|
-
request :
|
49
|
-
request :
|
50
|
-
request :
|
51
|
-
request :
|
53
|
+
request :initiate_multipart_upload
|
54
|
+
request :upload_part
|
55
|
+
request :complete_multipart_upload
|
56
|
+
request :abort_multipart_upload
|
52
57
|
|
53
58
|
class Real
|
54
59
|
# Initialize connection to OSS
|
@@ -121,6 +126,7 @@ module Fog
|
|
121
126
|
:access_key_secret => @aliyun_accesskey_secret
|
122
127
|
)
|
123
128
|
@oss_http = AliyunOssSdk::HTTP.new(@oss_config)
|
129
|
+
@oss_protocol = AliyunOssSdk::Protocol.new(@oss_config)
|
124
130
|
end
|
125
131
|
|
126
132
|
def reload
|
@@ -136,6 +142,16 @@ module Fog
|
|
136
142
|
end
|
137
143
|
end
|
138
144
|
|
145
|
+
def object_to_path(object_name=nil)
|
146
|
+
'/' + escape(object_name.to_s).gsub('%2F','/')
|
147
|
+
end
|
148
|
+
|
149
|
+
def escape(string)
|
150
|
+
string.gsub(/([^a-zA-Z0-9_.\-~\/]+)/) {
|
151
|
+
"%" + $1.unpack("H2" * $1.bytesize).join("%").upcase
|
152
|
+
}
|
153
|
+
end
|
154
|
+
|
139
155
|
def request(params)
|
140
156
|
method = params[:method]
|
141
157
|
time = Time.new.utc
|
data/lib/fog/aliyun/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-aliyun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Qinsi Deng, Jianxun Li, Jane Han, Guimin He
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,20 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
- - ">="
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 2.6.2
|
33
|
+
version: '3.4'
|
37
34
|
type: :development
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - "~>"
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 2.6.2
|
40
|
+
version: '3.4'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: pry-nav
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,28 +128,42 @@ dependencies:
|
|
134
128
|
requirements:
|
135
129
|
- - "~>"
|
136
130
|
- !ruby/object:Gem::Version
|
137
|
-
version: 0.
|
131
|
+
version: 0.8.0
|
138
132
|
type: :development
|
139
133
|
prerelease: false
|
140
134
|
version_requirements: !ruby/object:Gem::Requirement
|
141
135
|
requirements:
|
142
136
|
- - "~>"
|
143
137
|
- !ruby/object:Gem::Version
|
144
|
-
version: 0.
|
138
|
+
version: 0.8.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: addressable
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 2.8.0
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 2.8.0
|
145
153
|
- !ruby/object:Gem::Dependency
|
146
154
|
name: aliyun-sdk
|
147
155
|
requirement: !ruby/object:Gem::Requirement
|
148
156
|
requirements:
|
149
157
|
- - "~>"
|
150
158
|
- !ruby/object:Gem::Version
|
151
|
-
version: 0.
|
159
|
+
version: 0.8.0
|
152
160
|
type: :runtime
|
153
161
|
prerelease: false
|
154
162
|
version_requirements: !ruby/object:Gem::Requirement
|
155
163
|
requirements:
|
156
164
|
- - "~>"
|
157
165
|
- !ruby/object:Gem::Version
|
158
|
-
version: 0.
|
166
|
+
version: 0.8.0
|
159
167
|
- !ruby/object:Gem::Dependency
|
160
168
|
name: fog-core
|
161
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -325,22 +333,26 @@ files:
|
|
325
333
|
- lib/fog/aliyun/requests/compute/start_server.rb
|
326
334
|
- lib/fog/aliyun/requests/compute/stop_server.rb
|
327
335
|
- lib/fog/aliyun/requests/compute/unassociate_eip_address.rb
|
336
|
+
- lib/fog/aliyun/requests/storage/abort_multipart_upload.rb
|
337
|
+
- lib/fog/aliyun/requests/storage/complete_multipart_upload.rb
|
328
338
|
- lib/fog/aliyun/requests/storage/copy_object.rb
|
329
339
|
- lib/fog/aliyun/requests/storage/delete_bucket.rb
|
330
|
-
- lib/fog/aliyun/requests/storage/
|
340
|
+
- lib/fog/aliyun/requests/storage/delete_multiple_objects.rb
|
331
341
|
- lib/fog/aliyun/requests/storage/delete_object.rb
|
332
342
|
- lib/fog/aliyun/requests/storage/get_bucket.rb
|
333
|
-
- lib/fog/aliyun/requests/storage/
|
334
|
-
- lib/fog/aliyun/requests/storage/get_containers.rb
|
343
|
+
- lib/fog/aliyun/requests/storage/get_bucket_location.rb
|
335
344
|
- lib/fog/aliyun/requests/storage/get_object.rb
|
345
|
+
- lib/fog/aliyun/requests/storage/get_object_acl.rb
|
336
346
|
- lib/fog/aliyun/requests/storage/get_object_http_url.rb
|
337
347
|
- lib/fog/aliyun/requests/storage/get_object_https_url.rb
|
348
|
+
- lib/fog/aliyun/requests/storage/get_service.rb
|
338
349
|
- lib/fog/aliyun/requests/storage/head_object.rb
|
350
|
+
- lib/fog/aliyun/requests/storage/initiate_multipart_upload.rb
|
339
351
|
- lib/fog/aliyun/requests/storage/list_buckets.rb
|
340
352
|
- lib/fog/aliyun/requests/storage/list_objects.rb
|
341
353
|
- lib/fog/aliyun/requests/storage/put_bucket.rb
|
342
|
-
- lib/fog/aliyun/requests/storage/put_container.rb
|
343
354
|
- lib/fog/aliyun/requests/storage/put_object.rb
|
355
|
+
- lib/fog/aliyun/requests/storage/upload_part.rb
|
344
356
|
- lib/fog/aliyun/storage.rb
|
345
357
|
- lib/fog/aliyun/version.rb
|
346
358
|
- lib/fog/bin/aliyun.rb
|
@@ -363,7 +375,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
363
375
|
- !ruby/object:Gem::Version
|
364
376
|
version: '0'
|
365
377
|
requirements: []
|
366
|
-
rubygems_version: 3.0.
|
378
|
+
rubygems_version: 3.0.3
|
367
379
|
signing_key:
|
368
380
|
specification_version: 4
|
369
381
|
summary: Fog provider for Alibaba Cloud Web Services.
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Fog
|
4
|
-
module Aliyun
|
5
|
-
class Storage
|
6
|
-
class Real
|
7
|
-
# Delete an existing container
|
8
|
-
#
|
9
|
-
# ==== Parameters
|
10
|
-
# * container<~String> - Name of container to delete
|
11
|
-
# * options
|
12
|
-
#
|
13
|
-
def delete_container(container, options = {})
|
14
|
-
bucket = options[:bucket]
|
15
|
-
bucket ||= @aliyun_oss_bucket
|
16
|
-
object = container + '/'
|
17
|
-
resource = bucket + '/' + object
|
18
|
-
|
19
|
-
request(
|
20
|
-
expects: 204,
|
21
|
-
method: 'DELETE',
|
22
|
-
path: object,
|
23
|
-
bucket: bucket,
|
24
|
-
resource: resource
|
25
|
-
)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|