fog-aliyun 0.3.15 → 0.3.16
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/CHANGELOG.md +55 -0
- data/lib/fog/aliyun/models/storage/file.rb +2 -1
- data/lib/fog/aliyun/models/storage/files.rb +21 -37
- data/lib/fog/aliyun/requests/storage/copy_object.rb +1 -2
- data/lib/fog/aliyun/requests/storage/delete_bucket.rb +1 -2
- data/lib/fog/aliyun/requests/storage/delete_container.rb +1 -2
- data/lib/fog/aliyun/requests/storage/get_bucket.rb +10 -33
- data/lib/fog/aliyun/requests/storage/get_container.rb +0 -1
- data/lib/fog/aliyun/requests/storage/get_containers.rb +0 -6
- data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +7 -7
- data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +7 -7
- data/lib/fog/aliyun/requests/storage/head_object.rb +1 -2
- data/lib/fog/aliyun/requests/storage/list_objects.rb +4 -10
- data/lib/fog/aliyun/requests/storage/put_container.rb +1 -2
- data/lib/fog/aliyun/requests/storage/put_object.rb +28 -48
- data/lib/fog/aliyun/storage.rb +4 -21
- data/lib/fog/aliyun/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91aa2154dd185e6481eff2429ffc9c04e8651764dd8d6cf196c2b689a38c461b
|
4
|
+
data.tar.gz: a7aff361e70ead42b81f2d07aff5cbb92c5dcf6624f6dbfd0e0e1e80cc888a1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdc525d0d99894eb5e0dd63a6e0f4eff5fc9ebddce5c2eecbed0559010bfe25db134076d1f8a6bacc5f72d3efe4772efd02925e27481e8f3a413a6c5eb13ed01
|
7
|
+
data.tar.gz: f4726017f3fd50a33d4015adf8c1f5870645f2401acb79ab43b88fd845cef67fc838fb7a0044eed53c7007aa4ee2705819ecbe04e3f7eca3b12c78d90d6fbed8
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
## 0.3.17 (Unreleased)
|
2
|
+
## 0.3.16 (June 18, 2020)
|
3
|
+
|
4
|
+
IMPROVEMENTS:
|
5
|
+
- [Enhance tests][Files & Directory scenarios] Test get nested directories and files in nested directory [GH-98](https://github.com/fog/fog-aliyun/pull/98)
|
6
|
+
- remove get_bucket_location and use ruby sdk to improve performance when uploading object [GH-97](https://github.com/fog/fog-aliyun/pull/97)
|
7
|
+
- using bucket_exist to checking bucket [GH-95](https://github.com/fog/fog-aliyun/pull/95)
|
8
|
+
- add change log [GH-94](https://github.com/fog/fog-aliyun/pull/94)
|
9
|
+
|
10
|
+
BUG FIXES:
|
11
|
+
- fix delete all of files bug when specifying a prefix [GH-102](https://github.com/fog/fog-aliyun/pull/102)
|
12
|
+
|
13
|
+
## 0.3.15 (June 05, 2020)
|
14
|
+
|
15
|
+
BUG FIXES:
|
16
|
+
- change dependence ruby sdk to gems [GH-92](https://github.com/fog/fog-aliyun/pull/92)
|
17
|
+
|
18
|
+
## 0.3.13 (June 02, 2020)
|
19
|
+
|
20
|
+
IMPROVEMENTS:
|
21
|
+
- using ruby sdk to delete object [GH-90](https://github.com/fog/fog-aliyun/pull/90)
|
22
|
+
|
23
|
+
## 0.3.12 (May 28, 2020 )
|
24
|
+
|
25
|
+
BUG FIXES:
|
26
|
+
- add missing dependence [GH-88](https://github.com/fog/fog-aliyun/pull/88)
|
27
|
+
|
28
|
+
## 0.3.11 (May 25, 2020)
|
29
|
+
|
30
|
+
IMPROVEMENTS:
|
31
|
+
- using oss ruby sdk to improve downloading object performance [GH-86](https://github.com/fog/fog-aliyun/pull/86)
|
32
|
+
- Add performance tests [GH-85](https://github.com/fog/fog-aliyun/pull/85)
|
33
|
+
- [Enhance tests][Entity operations]Add tests for each type of entity that validates the CURD operations [GH-84](https://github.com/fog/fog-aliyun/pull/84)
|
34
|
+
- [Enhance tests][Auth & Connectivity scenarios] Test region is selected according to provider configuration [GH-83](https://github.com/fog/fog-aliyun/pull/83)
|
35
|
+
- [Enhance tests][Files & Directory scenarios] test file listing using parameters such as prefix, marker, delimeter and maxKeys [GH-82](https://github.com/fog/fog-aliyun/pull/82)
|
36
|
+
- [Enhance tests][Files & Directory scenarios]test directory listing using parameters such as prefix, marker, delimeter and maxKeys [GH-81](https://github.com/fog/fog-aliyun/pull/81)
|
37
|
+
- [Enhance tests][Files & Directory scenarios]Test that it is possible to upload (write) large file (multi part upload) [GH-79](https://github.com/fog/fog-aliyun/pull/79)
|
38
|
+
- upgrade deprecated code [GH-78](https://github.com/fog/fog-aliyun/pull/78)
|
39
|
+
- improve fog/integration_spec [GH-77](https://github.com/fog/fog-aliyun/pull/77)
|
40
|
+
- [Enhance tests][Files & Directory scenarios]Test that it is possible to upload (write) a file [GH-76](https://github.com/fog/fog-aliyun/pull/76)
|
41
|
+
- upgrade deprecated code [GH-74](https://github.com/fog/fog-aliyun/pull/74)
|
42
|
+
- support https scheme [GH-71](https://github.com/fog/fog-aliyun/pull/71)
|
43
|
+
- [Enhance tests][Files & Directory scenarios]Test that it is possible to destroy a file/directory [GH-69](https://github.com/fog/fog-aliyun/pull/69)
|
44
|
+
- improve fog/integration_spec [GH-68](https://github.com/fog/fog-aliyun/pull/68)
|
45
|
+
- Implement basic integration tests [GH-66](https://github.com/fog/fog-aliyun/pull/66)
|
46
|
+
|
47
|
+
## 0.3.10 (May 07, 2020)
|
48
|
+
|
49
|
+
IMPROVEMENTS:
|
50
|
+
- Set max limitation to 1000 when get objects [GH-64](https://github.com/fog/fog-aliyun/pull/64)
|
51
|
+
|
52
|
+
## 0.3.9 (May 07, 2020)
|
53
|
+
|
54
|
+
BUG FIXES:
|
55
|
+
- diectories.get supports options to filter the specified objects [GH-62](https://github.com/fog/fog-aliyun/pull/62)
|
@@ -120,7 +120,8 @@ module Fog
|
|
120
120
|
directory_key + '/' + key
|
121
121
|
end
|
122
122
|
if body.is_a?(::File)
|
123
|
-
|
123
|
+
service.put_object(object, body, options.merge(bucket: bucket_name))
|
124
|
+
data = service.head_object(object, bucket: bucket_name)
|
124
125
|
elsif body.is_a?(String)
|
125
126
|
data = service.put_object_with_body(object, body, options.merge(bucket: bucket_name)).data
|
126
127
|
else
|
@@ -36,14 +36,11 @@ module Fog
|
|
36
36
|
# The bucket name can not contain '/', so if directory_key, return directory.
|
37
37
|
if directory_key.include? '/'
|
38
38
|
directory_key
|
39
|
+
elsif service.bucket_exists?(directory_key)
|
40
|
+
bucket_name = directory_key
|
41
|
+
directory_key = ''
|
39
42
|
else
|
40
|
-
|
41
|
-
if data.class == Hash && data.key?('Code') && !data['Code'].nil? && !data['Code'].empty?
|
42
|
-
directory_key
|
43
|
-
else
|
44
|
-
bucket_name = directory_key
|
45
|
-
directory_key = ''
|
46
|
-
end
|
43
|
+
directory_key
|
47
44
|
end
|
48
45
|
end
|
49
46
|
return bucket_name, directory_key
|
@@ -51,37 +48,24 @@ module Fog
|
|
51
48
|
|
52
49
|
def all(options = {})
|
53
50
|
requires :directory
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
}
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
content_length = file['Size'][0].to_i
|
72
|
-
key = file['Key'][0]
|
73
|
-
lastModified = file['LastModified'][0]
|
74
|
-
last_modified = (Time.parse(lastModified).localtime if !lastModified.nil? && lastModified != '')
|
75
|
-
type = file['Type'][0]
|
76
|
-
data[i] = { content_length: content_length,
|
77
|
-
key: key,
|
78
|
-
last_modified: last_modified,
|
79
|
-
etag: file['ETag'][0],
|
80
|
-
object_type: type }
|
81
|
-
i += 1
|
51
|
+
options = {
|
52
|
+
'delimiter' => delimiter,
|
53
|
+
'marker' => marker,
|
54
|
+
'max-keys' => max_keys.to_i,
|
55
|
+
'prefix' => prefix
|
56
|
+
}.merge!(options)
|
57
|
+
options = options.reject {|key,value| value.nil? || value.to_s.empty?}
|
58
|
+
merge_attributes(options)
|
59
|
+
parent = directory.collection.get(
|
60
|
+
directory.key,
|
61
|
+
options
|
62
|
+
)
|
63
|
+
if parent
|
64
|
+
merge_attributes(parent.files.attributes)
|
65
|
+
load(parent.files.map {|file| file.attributes})
|
66
|
+
else
|
67
|
+
nil
|
82
68
|
end
|
83
|
-
|
84
|
-
load(data)
|
85
69
|
end
|
86
70
|
|
87
71
|
alias each_file_this_page each
|
@@ -4,6 +4,10 @@ module Fog
|
|
4
4
|
module Aliyun
|
5
5
|
class Storage
|
6
6
|
class Real
|
7
|
+
def bucket_exists?(bucket_name)
|
8
|
+
@oss_client.bucket_exists?(bucket_name)
|
9
|
+
end
|
10
|
+
|
7
11
|
def get_bucket(bucket, options = {})
|
8
12
|
prefix = options['prefix']
|
9
13
|
marker = options['marker']
|
@@ -36,33 +40,12 @@ module Fog
|
|
36
40
|
method: 'GET',
|
37
41
|
bucket: bucket,
|
38
42
|
resource: resource,
|
39
|
-
location: get_bucket_location(bucket),
|
40
43
|
path: path
|
41
44
|
)
|
42
45
|
xml = ret.data[:body]
|
43
46
|
XmlSimple.xml_in(xml)
|
44
47
|
end
|
45
48
|
|
46
|
-
def get_bucket_location(bucket)
|
47
|
-
attribute = '?location'
|
48
|
-
resource = bucket + '/' + attribute
|
49
|
-
ret = request(
|
50
|
-
expects: [200, 203, 403, 404],
|
51
|
-
method: 'GET',
|
52
|
-
path: attribute,
|
53
|
-
bucket: bucket,
|
54
|
-
resource: resource
|
55
|
-
)
|
56
|
-
# If there is an error, it will return a Hash with error code, host id and others
|
57
|
-
# If can not get a valid location, will return one using region
|
58
|
-
location = XmlSimple.xml_in(ret.data[:body])
|
59
|
-
if location.class == Hash && location.key?('HostId')
|
60
|
-
value = location['HostId']
|
61
|
-
location = value[0].split('.')[1]
|
62
|
-
end
|
63
|
-
location ||= 'oss-' + @aliyun_region_id
|
64
|
-
end
|
65
|
-
|
66
49
|
def get_bucket_acl(bucket)
|
67
50
|
attribute = '?acl'
|
68
51
|
resource = bucket + '/' + attribute
|
@@ -71,8 +54,7 @@ module Fog
|
|
71
54
|
method: 'GET',
|
72
55
|
path: attribute,
|
73
56
|
bucket: bucket,
|
74
|
-
resource: resource
|
75
|
-
location: get_bucket_location(bucket)
|
57
|
+
resource: resource
|
76
58
|
)
|
77
59
|
XmlSimple.xml_in(ret.data[:body])['AccessControlList'][0]['Grant'][0]
|
78
60
|
end
|
@@ -85,8 +67,7 @@ module Fog
|
|
85
67
|
method: 'GET',
|
86
68
|
path: attribute,
|
87
69
|
bucket: bucket,
|
88
|
-
resource: resource
|
89
|
-
location: get_bucket_location(bucket)
|
70
|
+
resource: resource
|
90
71
|
)
|
91
72
|
XmlSimple.xml_in(ret.data[:body])['CORSRule'][0] if ret.data[:status] != 404
|
92
73
|
end
|
@@ -99,8 +80,7 @@ module Fog
|
|
99
80
|
method: 'GET',
|
100
81
|
path: attribute,
|
101
82
|
bucket: bucket,
|
102
|
-
resource: resource
|
103
|
-
location: get_bucket_location(bucket)
|
83
|
+
resource: resource
|
104
84
|
)
|
105
85
|
XmlSimple.xml_in(ret.data[:body])['Rule'][0] if ret.data[:status] != 404
|
106
86
|
end
|
@@ -113,8 +93,7 @@ module Fog
|
|
113
93
|
method: 'GET',
|
114
94
|
path: attribute,
|
115
95
|
bucket: bucket,
|
116
|
-
resource: resource
|
117
|
-
location: get_bucket_location(bucket)
|
96
|
+
resource: resource
|
118
97
|
)
|
119
98
|
XmlSimple.xml_in(ret.data[:body])['LoggingEnabled'][0]['TargetPrefix']
|
120
99
|
end
|
@@ -127,8 +106,7 @@ module Fog
|
|
127
106
|
method: 'GET',
|
128
107
|
path: attribute,
|
129
108
|
bucket: bucket,
|
130
|
-
resource: resource
|
131
|
-
location: get_bucket_location(bucket)
|
109
|
+
resource: resource
|
132
110
|
)
|
133
111
|
XmlSimple.xml_in(ret.data[:body])
|
134
112
|
end
|
@@ -141,8 +119,7 @@ module Fog
|
|
141
119
|
method: 'GET',
|
142
120
|
path: attribute,
|
143
121
|
bucket: bucket,
|
144
|
-
resource: resource
|
145
|
-
location: get_bucket_location(bucket)
|
122
|
+
resource: resource
|
146
123
|
)
|
147
124
|
XmlSimple.xml_in(ret.data[:body]) if ret.data[:status] != 404
|
148
125
|
end
|
@@ -42,18 +42,12 @@ module Fog
|
|
42
42
|
path += '?delimiter=' + delimiter
|
43
43
|
end
|
44
44
|
|
45
|
-
endpoint = options[:endpoint]
|
46
|
-
if endpoint.nil?
|
47
|
-
location = get_bucket_location(bucket)
|
48
|
-
end
|
49
45
|
resource = bucket + '/'
|
50
46
|
ret = request(
|
51
47
|
expects: [200, 203, 400],
|
52
48
|
method: 'GET',
|
53
49
|
path: path,
|
54
50
|
resource: resource,
|
55
|
-
endpoint: endpoint,
|
56
|
-
location: location,
|
57
51
|
bucket: bucket
|
58
52
|
)
|
59
53
|
xml = ret.data[:body]
|
@@ -16,20 +16,20 @@ module Fog
|
|
16
16
|
# * body<~String> - url for object
|
17
17
|
def get_object_http_url_public(object, expires, options = {})
|
18
18
|
options = options.reject { |_key, value| value.nil? }
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
bucket_name = options[:bucket]
|
20
|
+
bucket_name ||= @aliyun_oss_bucket
|
21
|
+
bucket = @oss_client.get_bucket(bucket_name)
|
22
|
+
acl = bucket.acl()
|
23
23
|
|
24
24
|
if acl == 'private'
|
25
25
|
expires_time = (Time.now.to_i + (expires.nil? ? 0 : expires.to_i)).to_s
|
26
|
-
resource =
|
26
|
+
resource = bucket_name + '/' + object
|
27
27
|
signature = sign('GET', expires_time, nil, resource)
|
28
|
-
'http://' +
|
28
|
+
'http://' + bucket_name + '.' + @host + '/' + object +
|
29
29
|
'?OSSAccessKeyId=' + @aliyun_accesskey_id + '&Expires=' + expires_time +
|
30
30
|
'&Signature=' + URI.encode(signature, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
31
31
|
elsif acl == 'public-read' || acl == 'public-read-write'
|
32
|
-
'http://' +
|
32
|
+
'http://' + bucket_name + '.' + @host + '/' + object
|
33
33
|
else
|
34
34
|
'acl is wrong with value:' + acl
|
35
35
|
end
|
@@ -16,20 +16,20 @@ module Fog
|
|
16
16
|
# * body<~String> - url for object
|
17
17
|
def get_object_https_url_public(object, expires, options = {})
|
18
18
|
options = options.reject { |_key, value| value.nil? }
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
bucket_name = options[:bucket]
|
20
|
+
bucket_name ||= @aliyun_oss_bucket
|
21
|
+
bucket = @oss_client.get_bucket(bucket_name)
|
22
|
+
acl = bucket.acl()
|
23
23
|
|
24
24
|
if acl == 'private'
|
25
25
|
expires_time = (Time.now.to_i + (expires.nil? ? 0 : expires.to_i)).to_s
|
26
|
-
resource =
|
26
|
+
resource = bucket_name + '/' + object
|
27
27
|
signature = sign('GET', expires_time, nil, resource)
|
28
|
-
'https://' +
|
28
|
+
'https://' + bucket_name + '.' + @host + '/' + object +
|
29
29
|
'?OSSAccessKeyId=' + @aliyun_accesskey_id + '&Expires=' + expires_time +
|
30
30
|
'&Signature=' + URI.encode(signature, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
31
31
|
elsif acl == 'public-read' || acl == 'public-read-write'
|
32
|
-
'https://' +
|
32
|
+
'https://' + bucket_name + '.' + @host + '/' + object
|
33
33
|
else
|
34
34
|
'acl is wrong with value:' + acl
|
35
35
|
end
|
@@ -45,9 +45,7 @@ module Fog
|
|
45
45
|
XmlSimple.xml_in(xml)
|
46
46
|
end
|
47
47
|
|
48
|
-
def list_multipart_uploads(bucket,
|
49
|
-
location ||= get_bucket_location(bucket)
|
50
|
-
|
48
|
+
def list_multipart_uploads(bucket, _options = {})
|
51
49
|
path = '?uploads'
|
52
50
|
resource = bucket + '/' + path
|
53
51
|
|
@@ -56,15 +54,12 @@ module Fog
|
|
56
54
|
method: 'GET',
|
57
55
|
path: path,
|
58
56
|
bucket: bucket,
|
59
|
-
resource: resource
|
60
|
-
location: location
|
57
|
+
resource: resource
|
61
58
|
)
|
62
59
|
XmlSimple.xml_in(ret.data[:body])['Upload']
|
63
60
|
end
|
64
61
|
|
65
|
-
def list_parts(bucket, object,
|
66
|
-
location ||= get_bucket_location(bucket)
|
67
|
-
|
62
|
+
def list_parts(bucket, object, uploadid, _options = {})
|
68
63
|
path = object + '?uploadId=' + uploadid
|
69
64
|
resource = bucket + '/' + path
|
70
65
|
|
@@ -73,8 +68,7 @@ module Fog
|
|
73
68
|
method: 'GET',
|
74
69
|
path: path,
|
75
70
|
bucket: bucket,
|
76
|
-
resource: resource
|
77
|
-
location: location
|
71
|
+
resource: resource
|
78
72
|
)
|
79
73
|
XmlSimple.xml_in(ret.data[:body])['Part']
|
80
74
|
end
|
@@ -10,40 +10,29 @@ module Fog
|
|
10
10
|
# * object<~String> - Name of object to look for
|
11
11
|
#
|
12
12
|
def put_object(object, file = nil, options = {})
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
resource = bucket + '/' + object
|
23
|
-
request(
|
24
|
-
expects: [200, 203],
|
25
|
-
method: 'PUT',
|
26
|
-
path: object,
|
27
|
-
bucket: bucket,
|
28
|
-
resource: resource,
|
29
|
-
body: body,
|
30
|
-
location: get_bucket_location(bucket)
|
31
|
-
)
|
13
|
+
bucket_name = options[:bucket]
|
14
|
+
bucket_name ||= @aliyun_oss_bucket
|
15
|
+
bucket = @oss_client.get_bucket(bucket_name)
|
16
|
+
return bucket.put_object(object) if file.nil?
|
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)
|
32
22
|
end
|
33
23
|
|
34
24
|
def put_object_with_body(object, body, options = {})
|
35
|
-
|
36
|
-
|
25
|
+
bucket_name = options[:bucket]
|
26
|
+
bucket_name ||= @aliyun_oss_bucket
|
37
27
|
|
38
|
-
resource =
|
28
|
+
resource = bucket_name + '/' + object
|
39
29
|
request(
|
40
30
|
expects: [200, 203],
|
41
31
|
method: 'PUT',
|
42
32
|
path: object,
|
43
|
-
bucket:
|
33
|
+
bucket: bucket_name,
|
44
34
|
resource: resource,
|
45
|
-
body: body
|
46
|
-
location: get_bucket_location(bucket)
|
35
|
+
body: body
|
47
36
|
)
|
48
37
|
end
|
49
38
|
|
@@ -55,27 +44,24 @@ module Fog
|
|
55
44
|
method: 'PUT',
|
56
45
|
path: path,
|
57
46
|
bucket: bucket,
|
58
|
-
resource: resource
|
59
|
-
location: get_bucket_location(bucket)
|
47
|
+
resource: resource
|
60
48
|
)
|
61
49
|
end
|
62
50
|
|
63
51
|
def put_multipart_object(bucket, object, file)
|
64
|
-
location = get_bucket_location(bucket)
|
65
|
-
|
66
52
|
# find the right uploadid
|
67
|
-
uploads = list_multipart_uploads(bucket
|
53
|
+
uploads = list_multipart_uploads(bucket)
|
68
54
|
upload = (uploads&.find { |tmpupload| tmpupload['Key'][0] == object })
|
69
55
|
|
70
56
|
uploadedSize = 0
|
71
57
|
start_partNumber = 1
|
72
58
|
if !upload.nil?
|
73
59
|
uploadId = upload['UploadId'][0]
|
74
|
-
parts = list_parts(bucket, object,
|
60
|
+
parts = list_parts(bucket, object, uploadId)
|
75
61
|
if !parts.nil? && !parts.empty?
|
76
62
|
if parts[-1]['Size'][0].to_i != 5_242_880
|
77
63
|
# the part is the last one, if its size is over 5m, then finish this upload
|
78
|
-
complete_multipart_upload(bucket, object,
|
64
|
+
complete_multipart_upload(bucket, object, uploadId)
|
79
65
|
return
|
80
66
|
end
|
81
67
|
uploadedSize = (parts[0]['Size'][0].to_i * (parts.size - 1)) + parts[-1]['Size'][0].to_i
|
@@ -83,11 +69,11 @@ module Fog
|
|
83
69
|
end
|
84
70
|
else
|
85
71
|
# create upload ID
|
86
|
-
uploadId = initiate_multipart_upload(bucket, object
|
72
|
+
uploadId = initiate_multipart_upload(bucket, object)
|
87
73
|
end
|
88
74
|
|
89
75
|
if file.size <= uploadedSize
|
90
|
-
complete_multipart_upload(bucket, object,
|
76
|
+
complete_multipart_upload(bucket, object, uploadId)
|
91
77
|
return
|
92
78
|
end
|
93
79
|
|
@@ -96,14 +82,13 @@ module Fog
|
|
96
82
|
|
97
83
|
for i in start_partNumber..end_partNumber
|
98
84
|
body = file.read(5_242_880)
|
99
|
-
upload_part(bucket, object,
|
85
|
+
upload_part(bucket, object, i.to_s, uploadId, body)
|
100
86
|
end
|
101
87
|
|
102
|
-
complete_multipart_upload(bucket, object,
|
88
|
+
complete_multipart_upload(bucket, object, uploadId)
|
103
89
|
end
|
104
90
|
|
105
|
-
def initiate_multipart_upload(bucket, object
|
106
|
-
location ||= get_bucket_location(bucket)
|
91
|
+
def initiate_multipart_upload(bucket, object)
|
107
92
|
path = object + '?uploads'
|
108
93
|
resource = bucket + '/' + path
|
109
94
|
ret = request(
|
@@ -111,14 +96,12 @@ module Fog
|
|
111
96
|
method: 'POST',
|
112
97
|
path: path,
|
113
98
|
bucket: bucket,
|
114
|
-
resource: resource
|
115
|
-
location: location
|
99
|
+
resource: resource
|
116
100
|
)
|
117
101
|
XmlSimple.xml_in(ret.data[:body])['UploadId'][0]
|
118
102
|
end
|
119
103
|
|
120
|
-
def upload_part(bucket, object,
|
121
|
-
location ||= get_bucket_location(bucket)
|
104
|
+
def upload_part(bucket, object, partNumber, uploadId, body)
|
122
105
|
path = object + '?partNumber=' + partNumber + '&uploadId=' + uploadId
|
123
106
|
resource = bucket + '/' + path
|
124
107
|
request(
|
@@ -127,14 +110,12 @@ module Fog
|
|
127
110
|
path: path,
|
128
111
|
bucket: bucket,
|
129
112
|
resource: resource,
|
130
|
-
body: body
|
131
|
-
location: location
|
113
|
+
body: body
|
132
114
|
)
|
133
115
|
end
|
134
116
|
|
135
|
-
def complete_multipart_upload(bucket, object,
|
136
|
-
|
137
|
-
parts = list_parts(bucket, object, location, uploadId, options = {})
|
117
|
+
def complete_multipart_upload(bucket, object, uploadId)
|
118
|
+
parts = list_parts(bucket, object, uploadId, options = {})
|
138
119
|
request_part = []
|
139
120
|
return if parts.empty?
|
140
121
|
for i in 0..(parts.size - 1)
|
@@ -151,7 +132,6 @@ module Fog
|
|
151
132
|
path: path,
|
152
133
|
bucket: bucket,
|
153
134
|
resource: resource,
|
154
|
-
location: location,
|
155
135
|
body: body
|
156
136
|
)
|
157
137
|
end
|
data/lib/fog/aliyun/storage.rb
CHANGED
@@ -126,31 +126,14 @@ module Fog
|
|
126
126
|
time = Time.new.utc
|
127
127
|
date = time.strftime('%a, %d %b %Y %H:%M:%S GMT')
|
128
128
|
|
129
|
-
endpoint = params[:endpoint]
|
130
|
-
location = params[:location]
|
131
|
-
if endpoint
|
132
|
-
uri = URI.parse(endpoint)
|
133
|
-
host = uri.host
|
134
|
-
path = uri.path
|
135
|
-
port = uri.port
|
136
|
-
scheme = uri.scheme
|
137
|
-
elsif location
|
138
|
-
host = location + '.aliyuncs.com'
|
139
|
-
end
|
140
|
-
|
141
|
-
host ||= @host
|
142
|
-
path ||= @path
|
143
|
-
port ||= @port
|
144
|
-
scheme ||= @scheme
|
145
|
-
|
146
129
|
bucket = params[:bucket]
|
147
130
|
tmpHost = if bucket
|
148
|
-
bucket + '.' + host
|
131
|
+
bucket + '.' + @host
|
149
132
|
else
|
150
|
-
host
|
133
|
+
@host
|
151
134
|
end
|
152
135
|
|
153
|
-
@connection = Fog::Core::Connection.new("#{scheme}://#{tmpHost}", @persistent, @connection_options)
|
136
|
+
@connection = Fog::Core::Connection.new("#{@scheme}://#{tmpHost}", @persistent, @connection_options)
|
154
137
|
contentType = params[:contentType]
|
155
138
|
|
156
139
|
begin
|
@@ -166,7 +149,7 @@ module Fog
|
|
166
149
|
'Authorization' => 'OSS ' + @aliyun_accesskey_id + ':' + signature,
|
167
150
|
'Date' => date
|
168
151
|
}.merge!(params[:headers] || {}),
|
169
|
-
path: "#{path}/#{params[:path]}",
|
152
|
+
path: "#{@path}/#{params[:path]}",
|
170
153
|
query: params[:query]))
|
171
154
|
rescue Excon::Errors::HTTPStatusError => error
|
172
155
|
raise case error
|
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.3.
|
4
|
+
version: 0.3.16
|
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: 2020-06-
|
11
|
+
date: 2020-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -228,6 +228,7 @@ files:
|
|
228
228
|
- ".ruby-gemset"
|
229
229
|
- ".ruby-version"
|
230
230
|
- ".travis.yml"
|
231
|
+
- CHANGELOG.md
|
231
232
|
- CODE_OF_CONDUCT.md
|
232
233
|
- Gemfile
|
233
234
|
- LICENSE.txt
|