fog-aliyun 0.3.10 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +61 -3
- data/fog-aliyun.gemspec +3 -0
- data/lib/fog/aliyun.rb +6 -9
- data/lib/fog/aliyun/models/storage/directories.rb +4 -4
- data/lib/fog/aliyun/models/storage/directory.rb +4 -4
- data/lib/fog/aliyun/models/storage/file.rb +3 -3
- data/lib/fog/aliyun/models/storage/files.rb +39 -59
- data/lib/fog/aliyun/requests/storage/copy_object.rb +3 -5
- data/lib/fog/aliyun/requests/storage/delete_bucket.rb +3 -5
- data/lib/fog/aliyun/requests/storage/delete_container.rb +3 -5
- data/lib/fog/aliyun/requests/storage/delete_object.rb +5 -10
- data/lib/fog/aliyun/requests/storage/get_bucket.rb +18 -34
- data/lib/fog/aliyun/requests/storage/get_container.rb +2 -2
- data/lib/fog/aliyun/requests/storage/get_containers.rb +8 -3
- data/lib/fog/aliyun/requests/storage/get_object.rb +12 -25
- data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +2 -2
- data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +2 -2
- data/lib/fog/aliyun/requests/storage/head_object.rb +3 -5
- data/lib/fog/aliyun/requests/storage/list_buckets.rb +2 -2
- data/lib/fog/aliyun/requests/storage/list_objects.rb +15 -19
- data/lib/fog/aliyun/requests/storage/put_bucket.rb +2 -2
- data/lib/fog/aliyun/requests/storage/put_container.rb +3 -5
- data/lib/fog/aliyun/requests/storage/put_object.rb +24 -42
- data/lib/fog/aliyun/storage.rb +24 -10
- data/lib/fog/aliyun/version.rb +1 -1
- data/lib/fog/bin/aliyun.rb +1 -1
- metadata +44 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d434b8e3569bc8c5d6f4c0223d37f7affcb9bf3a78a744f3ebef9973b173400
|
4
|
+
data.tar.gz: ca6e6783bfd1c0169c4ac2588af139ce9b6373ecc76d27addabab82a7fbdbf0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f75f52309dc5433c02635faf7b572a6ab3371cdffacbf26ca1597da2d9107e9d89ffa24923d0921f2204c45db88f1eb60136bde8b29fc8e90756f096a22e685
|
7
|
+
data.tar.gz: b37f84ef7c0a17dc8d7891e317b3937e6a7097f90177368761b30aae36ddb179242e22e0880c25ee94da0c2c2dceb2f4669bfd29584e70fafd43b9aa16c93b64
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -30,9 +30,9 @@ Since it's a bad practice to have your credentials in source code, you should lo
|
|
30
30
|
|
31
31
|
```
|
32
32
|
default:
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
aliyun_accesskey_id: "<YOUR_ACCESS_KEY_ID>"
|
34
|
+
aliyun_accesskey_secret: "<YOUR_SECRET_ACCESS_KEY>"
|
35
|
+
aliyun_region_id: "<YOUR_TARGET_REGION>"
|
36
36
|
```
|
37
37
|
|
38
38
|
### Connecting to OSS
|
@@ -307,6 +307,64 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
307
307
|
|
308
308
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
309
309
|
|
310
|
+
## Testing
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
To run test suite use the following command:
|
315
|
+
|
316
|
+
```
|
317
|
+
rake spec
|
318
|
+
```
|
319
|
+
|
320
|
+
### Code coverage
|
321
|
+
|
322
|
+
To run test suite with code coverage:
|
323
|
+
|
324
|
+
```
|
325
|
+
export COVERAGE=true
|
326
|
+
rake spec
|
327
|
+
```
|
328
|
+
|
329
|
+
The result will be generated in `coverage` folder.
|
330
|
+
|
331
|
+
### Integration tests
|
332
|
+
|
333
|
+
To run integration tests please prepare a set of AliCloud credentials to be used by integration tests.
|
334
|
+
|
335
|
+
Define the credentials and bucket in `~/.fog` file in using following format:
|
336
|
+
|
337
|
+
```
|
338
|
+
default:
|
339
|
+
aliyun_accesskey_id: "...access key..." # You can create a set of credentials
|
340
|
+
aliyun_accesskey_secret: "...secret..." # using Alicloud console portal
|
341
|
+
aliyun_region_id: "...region name..." # Example: cn-shanghai
|
342
|
+
aliyun_oss_bucket: "...name of the bucket..." # Example: fog-integration-test-bucket
|
343
|
+
```
|
344
|
+
|
345
|
+
WARNING: Do NOT use any productive account credentials and buckets for the testing, it may be harmful to your data!
|
346
|
+
|
347
|
+
The tests are using [https://github.com/aliyun/aliyun-cli#installation](Aliyun CLI) to setup integration bucket and content for tests,
|
348
|
+
please install it locally before running integration tests.
|
349
|
+
|
350
|
+
Aliyun CLI will be configured automatically as part of test execution using the credentials provided for fog connection.
|
351
|
+
|
352
|
+
Then run the test suite with `INTEGRATION` environment variable to activate integration tests:
|
353
|
+
|
354
|
+
```
|
355
|
+
export INTEGRATION=true
|
356
|
+
rake spec
|
357
|
+
```
|
358
|
+
|
359
|
+
### Performance test
|
360
|
+
|
361
|
+
Performance tests are providing memory consumption report for download/upload operations.
|
362
|
+
|
363
|
+
```
|
364
|
+
export PERFORMANCE=true
|
365
|
+
rake spec
|
366
|
+
```
|
367
|
+
|
310
368
|
## License
|
311
369
|
|
312
370
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/fog-aliyun.gemspec
CHANGED
@@ -26,6 +26,9 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency 'rake'
|
27
27
|
spec.add_development_dependency 'rspec'
|
28
28
|
spec.add_development_dependency 'rubocop'
|
29
|
+
spec.add_development_dependency 'simplecov'
|
30
|
+
spec.add_development_dependency 'memory_profiler'
|
31
|
+
spec.add_development_dependency 'aliyun-sdk'
|
29
32
|
|
30
33
|
spec.add_dependency 'fog-core'
|
31
34
|
spec.add_dependency 'fog-json'
|
data/lib/fog/aliyun.rb
CHANGED
@@ -2,19 +2,16 @@
|
|
2
2
|
|
3
3
|
require 'fog/core'
|
4
4
|
require 'fog/json'
|
5
|
-
require '
|
5
|
+
require File.expand_path('../aliyun/version', __FILE__)
|
6
6
|
|
7
7
|
module Fog
|
8
|
-
module Compute
|
9
|
-
autoload :Aliyun, 'fog/aliyun/compute'
|
10
|
-
end
|
11
|
-
|
12
|
-
module Storage
|
13
|
-
autoload :Aliyun, 'fog/aliyun/storage'
|
14
|
-
end
|
15
|
-
|
16
8
|
module Aliyun
|
17
9
|
extend Fog::Provider
|
10
|
+
|
11
|
+
# Services
|
12
|
+
autoload :Compute, File.expand_path('../aliyun/compute', __FILE__)
|
13
|
+
autoload :Storage, File.expand_path('../aliyun/storage', __FILE__)
|
14
|
+
|
18
15
|
service(:compute, 'Compute')
|
19
16
|
service(:storage, 'Storage')
|
20
17
|
end
|
@@ -4,10 +4,10 @@ require 'fog/core/collection'
|
|
4
4
|
require 'fog/aliyun/models/storage/directory'
|
5
5
|
|
6
6
|
module Fog
|
7
|
-
module
|
8
|
-
class
|
7
|
+
module Aliyun
|
8
|
+
class Storage
|
9
9
|
class Directories < Fog::Collection
|
10
|
-
model Fog::Storage::
|
10
|
+
model Fog::Aliyun::Storage::Directory
|
11
11
|
|
12
12
|
def all
|
13
13
|
containers = service.get_containers
|
@@ -72,7 +72,7 @@ module Fog
|
|
72
72
|
else
|
73
73
|
new(key: '')
|
74
74
|
end
|
75
|
-
rescue Fog::Storage::
|
75
|
+
rescue Fog::Aliyun::Storage::NotFound
|
76
76
|
nil
|
77
77
|
end
|
78
78
|
end
|
@@ -4,8 +4,8 @@ require 'fog/core/model'
|
|
4
4
|
require 'fog/aliyun/models/storage/files'
|
5
5
|
|
6
6
|
module Fog
|
7
|
-
module
|
8
|
-
class
|
7
|
+
module Aliyun
|
8
|
+
class Storage
|
9
9
|
class Directory < Fog::Model
|
10
10
|
identity :key, :aliases => ['Key', 'Name', 'name']
|
11
11
|
|
@@ -20,14 +20,14 @@ module Fog
|
|
20
20
|
service.delete_container(key)
|
21
21
|
true
|
22
22
|
else
|
23
|
-
raise Fog::Storage::
|
23
|
+
raise Fog::Aliyun::Storage::Error, ' Forbidden: Direction not empty!'
|
24
24
|
false
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def files
|
29
29
|
@files ||= begin
|
30
|
-
Fog::Storage::
|
30
|
+
Fog::Aliyun::Storage::Files.new(
|
31
31
|
directory: self,
|
32
32
|
service: service
|
33
33
|
)
|
@@ -3,8 +3,8 @@
|
|
3
3
|
require 'fog/core/model'
|
4
4
|
|
5
5
|
module Fog
|
6
|
-
module
|
7
|
-
class
|
6
|
+
module Aliyun
|
7
|
+
class Storage
|
8
8
|
class File < Fog::Model
|
9
9
|
identity :key, aliases: ['Key', 'Name', 'name']
|
10
10
|
attribute :date, aliases: 'Date'
|
@@ -124,7 +124,7 @@ module Fog
|
|
124
124
|
elsif body.is_a?(String)
|
125
125
|
data = service.put_object_with_body(object, body, options.merge(bucket: bucket_name)).data
|
126
126
|
else
|
127
|
-
raise Fog::Storage::
|
127
|
+
raise Fog::Aliyun::Storage::Error, " Forbidden: Invalid body type: #{body.class}!"
|
128
128
|
end
|
129
129
|
update_attributes_from(data)
|
130
130
|
refresh_metadata
|
@@ -2,10 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'fog/core/collection'
|
4
4
|
require 'fog/aliyun/models/storage/file'
|
5
|
+
require 'aliyun/oss'
|
5
6
|
|
6
7
|
module Fog
|
7
|
-
module
|
8
|
-
class
|
8
|
+
module Aliyun
|
9
|
+
class Storage
|
9
10
|
class Files < Fog::Collection
|
10
11
|
attribute :directory
|
11
12
|
attribute :limit
|
@@ -17,7 +18,7 @@ module Fog
|
|
17
18
|
attribute :marker, :aliases => 'Marker'
|
18
19
|
attribute :max_keys, :aliases => ['MaxKeys', 'max-keys']
|
19
20
|
|
20
|
-
model Fog::Storage::
|
21
|
+
model Fog::Aliyun::Storage::File
|
21
22
|
|
22
23
|
# check_directory_key have two functions:
|
23
24
|
# 1. trim the directory_key suffix '/'
|
@@ -48,12 +49,20 @@ module Fog
|
|
48
49
|
return bucket_name, directory_key
|
49
50
|
end
|
50
51
|
|
51
|
-
def all(
|
52
|
+
def all(options = {})
|
52
53
|
requires :directory
|
53
54
|
bucket_name, directory_key = check_directory_key(directory.key)
|
54
|
-
|
55
|
+
remap_attributes(options, {
|
56
|
+
:delimiter => 'delimiter',
|
57
|
+
:marker => 'marker',
|
58
|
+
:max_keys => 'max-keys',
|
59
|
+
:prefix => 'prefix'
|
60
|
+
})
|
61
|
+
prefix_value = options['prefix']
|
55
62
|
prefix_value = directory_key + '/' + prefix if directory_key != '' && directory_key != '.' && !directory_key.nil?
|
56
|
-
|
63
|
+
options['prefix'] = prefix_value
|
64
|
+
options['bucket'] = bucket_name
|
65
|
+
files = service.list_objects(options)['Contents']
|
57
66
|
return if files.nil?
|
58
67
|
data = []
|
59
68
|
i = 0
|
@@ -102,63 +111,34 @@ module Fog
|
|
102
111
|
end
|
103
112
|
begin
|
104
113
|
data = service.get_object(object, nil, bucket: bucket_name)
|
105
|
-
|
106
|
-
|
107
|
-
|
114
|
+
lastModified = data['headers'][:last_modified]
|
115
|
+
last_modified = (Time.parse(lastModified).localtime if !lastModified.nil? && lastModified != '')
|
116
|
+
|
117
|
+
date = data['headers'][:date]
|
118
|
+
date = (Time.parse(date).localtime if !date.nil? && date != '')
|
119
|
+
file_data = {
|
120
|
+
body: data[:body],
|
121
|
+
content_length: data['headers'][:content_length].to_i,
|
122
|
+
key: key,
|
123
|
+
last_modified: last_modified,
|
124
|
+
content_type: data['headers'][:content_type],
|
125
|
+
etag: data['headers'][:etag],
|
126
|
+
date: date,
|
127
|
+
connection: data['headers'][:connection],
|
128
|
+
accept_ranges: data['headers'][:accept_ranges],
|
129
|
+
server: data['headers'][:server],
|
130
|
+
object_type: data['headers'][:x_oss_object_type]
|
131
|
+
}
|
132
|
+
|
133
|
+
new(file_data)
|
134
|
+
rescue AliyunOssSdk::ServerError => error
|
135
|
+
case error.error_code
|
136
|
+
when %r{NoSuchKey},%r{SymlinkTargetNotExist}
|
108
137
|
nil
|
109
138
|
else
|
110
139
|
raise(error)
|
111
140
|
end
|
112
141
|
end
|
113
|
-
|
114
|
-
contentLen = data[:headers]['Content-Length'].to_i
|
115
|
-
|
116
|
-
if block_given?
|
117
|
-
pagesNum = (contentLen + Excon::CHUNK_SIZE - 1) / Excon::CHUNK_SIZE
|
118
|
-
|
119
|
-
for i in 1..pagesNum
|
120
|
-
_start = (i - 1) * Excon::CHUNK_SIZE
|
121
|
-
_end = i * Excon::CHUNK_SIZE - 1
|
122
|
-
range = "#{_start}-#{_end}"
|
123
|
-
begin
|
124
|
-
data = service.get_object(object, range, bucket: bucket_name)
|
125
|
-
chunk = data[:body]
|
126
|
-
rescue StandardError => error
|
127
|
-
case error.response.body
|
128
|
-
when %r{<Code>NoSuchKey</Code>},%r{<Code>SymlinkTargetNotExist</Code>}
|
129
|
-
chunk = ''
|
130
|
-
else
|
131
|
-
raise(error)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
yield(chunk)
|
135
|
-
body = nil
|
136
|
-
end
|
137
|
-
else
|
138
|
-
body = data[:body]
|
139
|
-
end
|
140
|
-
|
141
|
-
lastModified = data[:headers]['Last-Modified']
|
142
|
-
last_modified = (Time.parse(lastModified).localtime if !lastModified.nil? && lastModified != '')
|
143
|
-
|
144
|
-
date = data[:headers]['Date']
|
145
|
-
date = (Time.parse(date).localtime if !date.nil? && date != '')
|
146
|
-
file_data = {
|
147
|
-
body: body,
|
148
|
-
content_length: contentLen,
|
149
|
-
key: key,
|
150
|
-
last_modified: last_modified,
|
151
|
-
content_type: data[:headers]['Content-Type'],
|
152
|
-
etag: data[:headers]['ETag'],
|
153
|
-
date: date,
|
154
|
-
connection: data[:headers]['Connection'],
|
155
|
-
accept_ranges: data[:headers]['Accept-Ranges'],
|
156
|
-
server: data[:headers]['Server'],
|
157
|
-
object_type: data[:headers]['x-oss-object-type'],
|
158
|
-
content_disposition: data[:headers]['Content-Disposition']
|
159
|
-
}
|
160
|
-
|
161
|
-
new(file_data)
|
162
142
|
end
|
163
143
|
|
164
144
|
def get_url(key)
|
@@ -225,7 +205,7 @@ module Fog
|
|
225
205
|
object_type: data[:headers]['x-oss-object-type']
|
226
206
|
}
|
227
207
|
new(file_data)
|
228
|
-
rescue Fog::Storage::
|
208
|
+
rescue Fog::Aliyun::Storage::NotFound
|
229
209
|
nil
|
230
210
|
end
|
231
211
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Fog
|
4
|
-
module
|
5
|
-
class
|
4
|
+
module Aliyun
|
5
|
+
class Storage
|
6
6
|
class Real
|
7
7
|
# Copy object
|
8
8
|
#
|
@@ -19,8 +19,6 @@ module Fog
|
|
19
19
|
source_bucket ||= bucket
|
20
20
|
target_bucket ||= bucket
|
21
21
|
headers = { 'x-oss-copy-source' => "/#{source_bucket}/#{source_object}" }
|
22
|
-
location = get_bucket_location(target_bucket)
|
23
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
24
22
|
resource = target_bucket + '/' + target_object
|
25
23
|
request(expects: [200, 203],
|
26
24
|
headers: headers,
|
@@ -28,7 +26,7 @@ module Fog
|
|
28
26
|
path: target_object,
|
29
27
|
bucket: target_bucket,
|
30
28
|
resource: resource,
|
31
|
-
|
29
|
+
location: get_bucket_location(bucket))
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Fog
|
4
|
-
module
|
5
|
-
class
|
4
|
+
module Aliyun
|
5
|
+
class Storage
|
6
6
|
class Real
|
7
7
|
# Delete an existing bucket
|
8
8
|
#
|
@@ -10,15 +10,13 @@ module Fog
|
|
10
10
|
# * bucket<~String> - Name of bucket to delete
|
11
11
|
#
|
12
12
|
def delete_bucket(bucket)
|
13
|
-
location = get_bucket_location(bucket)
|
14
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
15
13
|
resource = bucket + '/'
|
16
14
|
request(
|
17
15
|
expects: 204,
|
18
16
|
method: 'DELETE',
|
19
17
|
bucket: bucket,
|
20
18
|
resource: resource,
|
21
|
-
|
19
|
+
location: get_bucket_location(bucket)
|
22
20
|
)
|
23
21
|
end
|
24
22
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Fog
|
4
|
-
module
|
5
|
-
class
|
4
|
+
module Aliyun
|
5
|
+
class Storage
|
6
6
|
class Real
|
7
7
|
# Delete an existing container
|
8
8
|
#
|
@@ -13,8 +13,6 @@ module Fog
|
|
13
13
|
def delete_container(container, options = {})
|
14
14
|
bucket = options[:bucket]
|
15
15
|
bucket ||= @aliyun_oss_bucket
|
16
|
-
location = get_bucket_location(bucket)
|
17
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
18
16
|
object = container + '/'
|
19
17
|
resource = bucket + '/' + object
|
20
18
|
|
@@ -24,7 +22,7 @@ module Fog
|
|
24
22
|
path: object,
|
25
23
|
bucket: bucket,
|
26
24
|
resource: resource,
|
27
|
-
|
25
|
+
location: get_bucket_location(bucket)
|
28
26
|
)
|
29
27
|
end
|
30
28
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Fog
|
4
|
-
module
|
5
|
-
class
|
4
|
+
module Aliyun
|
5
|
+
class Storage
|
6
6
|
class Real
|
7
7
|
# Delete an existing object
|
8
8
|
#
|
@@ -12,8 +12,6 @@ module Fog
|
|
12
12
|
def delete_object(object, options = {})
|
13
13
|
bucket = options[:bucket]
|
14
14
|
bucket ||= @aliyun_oss_bucket
|
15
|
-
location = get_bucket_location(bucket)
|
16
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
17
15
|
resource = bucket + '/' + object
|
18
16
|
request(
|
19
17
|
expects: 204,
|
@@ -21,15 +19,11 @@ module Fog
|
|
21
19
|
path: object,
|
22
20
|
bucket: bucket,
|
23
21
|
resource: resource,
|
24
|
-
|
22
|
+
location: get_bucket_location(bucket)
|
25
23
|
)
|
26
24
|
end
|
27
25
|
|
28
26
|
def abort_multipart_upload(bucket, object, endpoint, uploadid)
|
29
|
-
if endpoint.nil?
|
30
|
-
location = get_bucket_location(bucket)
|
31
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
32
|
-
end
|
33
27
|
path = object + '?uploadId=' + uploadid
|
34
28
|
resource = bucket + '/' + path
|
35
29
|
|
@@ -39,7 +33,8 @@ module Fog
|
|
39
33
|
path: path,
|
40
34
|
bucket: bucket,
|
41
35
|
resource: resource,
|
42
|
-
endpoint: endpoint
|
36
|
+
endpoint: endpoint,
|
37
|
+
location: get_bucket_location(bucket)
|
43
38
|
)
|
44
39
|
end
|
45
40
|
end
|
@@ -1,25 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Fog
|
4
|
-
module
|
5
|
-
class
|
4
|
+
module Aliyun
|
5
|
+
class Storage
|
6
6
|
class Real
|
7
7
|
def get_bucket(bucket, options = {})
|
8
|
-
location = get_bucket_location(bucket)
|
9
|
-
# If there is an error, it will return a Hash with error code, host id and others
|
10
|
-
# If can not get a valid location, will return one using region
|
11
|
-
if location.class == Hash && location.key?('HostId')
|
12
|
-
value = location['HostId']
|
13
|
-
location = value[0].split('.')[1]
|
14
|
-
else
|
15
|
-
location = 'oss-' + @aliyun_region_id
|
16
|
-
end
|
17
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
18
|
-
|
19
8
|
prefix = options['prefix']
|
20
9
|
marker = options['marker']
|
21
10
|
# Set the GetBucket max limitation to 1000
|
22
|
-
maxKeys = options['
|
11
|
+
maxKeys = options['max-keys'] || 1000
|
23
12
|
maxKeys = [maxKeys, 1000].min
|
24
13
|
delimiter = options['delimiter']
|
25
14
|
path = ''
|
@@ -47,7 +36,7 @@ module Fog
|
|
47
36
|
method: 'GET',
|
48
37
|
bucket: bucket,
|
49
38
|
resource: resource,
|
50
|
-
|
39
|
+
location: get_bucket_location(bucket),
|
51
40
|
path: path
|
52
41
|
)
|
53
42
|
xml = ret.data[:body]
|
@@ -64,12 +53,17 @@ module Fog
|
|
64
53
|
bucket: bucket,
|
65
54
|
resource: resource
|
66
55
|
)
|
67
|
-
|
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
|
68
64
|
end
|
69
65
|
|
70
66
|
def get_bucket_acl(bucket)
|
71
|
-
location = get_bucket_location(bucket)
|
72
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
73
67
|
attribute = '?acl'
|
74
68
|
resource = bucket + '/' + attribute
|
75
69
|
ret = request(
|
@@ -78,14 +72,12 @@ module Fog
|
|
78
72
|
path: attribute,
|
79
73
|
bucket: bucket,
|
80
74
|
resource: resource,
|
81
|
-
|
75
|
+
location: get_bucket_location(bucket)
|
82
76
|
)
|
83
77
|
XmlSimple.xml_in(ret.data[:body])['AccessControlList'][0]['Grant'][0]
|
84
78
|
end
|
85
79
|
|
86
80
|
def get_bucket_CORSRules(bucket)
|
87
|
-
location = get_bucket_location(bucket)
|
88
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
89
81
|
attribute = '?cors'
|
90
82
|
resource = bucket + '/' + attribute
|
91
83
|
ret = request(
|
@@ -94,14 +86,12 @@ module Fog
|
|
94
86
|
path: attribute,
|
95
87
|
bucket: bucket,
|
96
88
|
resource: resource,
|
97
|
-
|
89
|
+
location: get_bucket_location(bucket)
|
98
90
|
)
|
99
91
|
XmlSimple.xml_in(ret.data[:body])['CORSRule'][0] if ret.data[:status] != 404
|
100
92
|
end
|
101
93
|
|
102
94
|
def get_bucket_lifecycle(bucket)
|
103
|
-
location = get_bucket_location(bucket)
|
104
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
105
95
|
attribute = '?lifecycle'
|
106
96
|
resource = bucket + '/' + attribute
|
107
97
|
ret = request(
|
@@ -110,14 +100,12 @@ module Fog
|
|
110
100
|
path: attribute,
|
111
101
|
bucket: bucket,
|
112
102
|
resource: resource,
|
113
|
-
|
103
|
+
location: get_bucket_location(bucket)
|
114
104
|
)
|
115
105
|
XmlSimple.xml_in(ret.data[:body])['Rule'][0] if ret.data[:status] != 404
|
116
106
|
end
|
117
107
|
|
118
108
|
def get_bucket_logging(bucket)
|
119
|
-
location = get_bucket_location(bucket)
|
120
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
121
109
|
attribute = '?logging'
|
122
110
|
resource = bucket + '/' + attribute
|
123
111
|
ret = request(
|
@@ -126,14 +114,12 @@ module Fog
|
|
126
114
|
path: attribute,
|
127
115
|
bucket: bucket,
|
128
116
|
resource: resource,
|
129
|
-
|
117
|
+
location: get_bucket_location(bucket)
|
130
118
|
)
|
131
119
|
XmlSimple.xml_in(ret.data[:body])['LoggingEnabled'][0]['TargetPrefix']
|
132
120
|
end
|
133
121
|
|
134
122
|
def get_bucket_referer(bucket)
|
135
|
-
location = get_bucket_location(bucket)
|
136
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
137
123
|
attribute = '?referer'
|
138
124
|
resource = bucket + '/' + attribute
|
139
125
|
ret = request(
|
@@ -142,14 +128,12 @@ module Fog
|
|
142
128
|
path: attribute,
|
143
129
|
bucket: bucket,
|
144
130
|
resource: resource,
|
145
|
-
|
131
|
+
location: get_bucket_location(bucket)
|
146
132
|
)
|
147
133
|
XmlSimple.xml_in(ret.data[:body])
|
148
134
|
end
|
149
135
|
|
150
136
|
def get_bucket_website(bucket)
|
151
|
-
location = get_bucket_location(bucket)
|
152
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
153
137
|
attribute = '?website'
|
154
138
|
resource = bucket + '/' + attribute
|
155
139
|
ret = request(
|
@@ -158,7 +142,7 @@ module Fog
|
|
158
142
|
path: attribute,
|
159
143
|
bucket: bucket,
|
160
144
|
resource: resource,
|
161
|
-
|
145
|
+
location: get_bucket_location(bucket)
|
162
146
|
)
|
163
147
|
XmlSimple.xml_in(ret.data[:body]) if ret.data[:status] != 404
|
164
148
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Fog
|
4
|
-
module
|
5
|
-
class
|
4
|
+
module Aliyun
|
5
|
+
class Storage
|
6
6
|
class Real
|
7
7
|
# List existing storage containers
|
8
8
|
#
|
@@ -42,13 +42,18 @@ module Fog
|
|
42
42
|
path += '?delimiter=' + delimiter
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
endpoint = options[:endpoint]
|
46
|
+
if endpoint.nil?
|
47
|
+
location = get_bucket_location(bucket)
|
48
|
+
end
|
46
49
|
resource = bucket + '/'
|
47
50
|
ret = request(
|
48
51
|
expects: [200, 203, 400],
|
49
52
|
method: 'GET',
|
50
53
|
path: path,
|
51
54
|
resource: resource,
|
55
|
+
endpoint: endpoint,
|
56
|
+
location: location,
|
52
57
|
bucket: bucket
|
53
58
|
)
|
54
59
|
xml = ret.data[:body]
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Fog
|
4
|
-
module
|
5
|
-
class
|
4
|
+
module Aliyun
|
5
|
+
class Storage
|
6
6
|
class Real
|
7
7
|
# Get details for object
|
8
8
|
#
|
@@ -11,30 +11,17 @@ module Fog
|
|
11
11
|
#
|
12
12
|
def get_object(object, range = nil, options = {})
|
13
13
|
options = options.reject { |_key, value| value.nil? }
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
bucket_name = options[:bucket]
|
15
|
+
bucket_name ||= @aliyun_oss_bucket
|
16
|
+
# Using OSS ruby SDK to fix performance issue
|
17
|
+
bucket = @oss_client.get_bucket(bucket_name)
|
18
|
+
body = Array.new
|
19
|
+
obj = bucket.get_object(object) do |chunk|
|
20
|
+
body << chunk
|
20
21
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
method: 'GET',
|
25
|
-
path: object,
|
26
|
-
bucket: bucket,
|
27
|
-
resource: resource,
|
28
|
-
endpoint: endpoint
|
29
|
-
}
|
30
|
-
|
31
|
-
if range
|
32
|
-
rangeStr = 'bytes=' + range
|
33
|
-
para[:headers] = { 'Range' => rangeStr }
|
34
|
-
end
|
35
|
-
|
36
|
-
response = request(para)
|
37
|
-
response.data
|
22
|
+
response = {}
|
23
|
+
obj.instance_variables.each {|var| response[var.to_s.delete("@")] = obj.instance_variable_get(var) }
|
24
|
+
response.merge({:body => body.join('')})
|
38
25
|
end
|
39
26
|
end
|
40
27
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Fog
|
4
|
-
module
|
5
|
-
class
|
4
|
+
module Aliyun
|
5
|
+
class Storage
|
6
6
|
class Real
|
7
7
|
# Get headers for object
|
8
8
|
#
|
@@ -12,8 +12,6 @@ module Fog
|
|
12
12
|
def head_object(object, options = {})
|
13
13
|
bucket = options[:bucket]
|
14
14
|
bucket ||= @aliyun_oss_bucket
|
15
|
-
location = get_bucket_location(bucket)
|
16
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
17
15
|
resource = bucket + '/' + object
|
18
16
|
ret = request(
|
19
17
|
expects: [200, 404],
|
@@ -21,7 +19,7 @@ module Fog
|
|
21
19
|
path: object,
|
22
20
|
bucket: bucket,
|
23
21
|
resource: resource,
|
24
|
-
|
22
|
+
location: get_bucket_location(bucket)
|
25
23
|
)
|
26
24
|
ret
|
27
25
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Fog
|
4
|
-
module
|
5
|
-
class
|
4
|
+
module Aliyun
|
5
|
+
class Storage
|
6
6
|
class Real
|
7
7
|
def list_objects(options = {})
|
8
|
-
bucket = options[
|
8
|
+
bucket = options['bucket']
|
9
9
|
bucket ||= @aliyun_oss_bucket
|
10
|
-
prefix = options[
|
11
|
-
marker = options[
|
10
|
+
prefix = options['prefix']
|
11
|
+
marker = options['marker']
|
12
12
|
# Set the ListObjects max limitation to 1000
|
13
|
-
maxKeys = options[
|
13
|
+
maxKeys = options['max-keys'] || 1000
|
14
14
|
maxKeys = [maxKeys, 1000].min
|
15
|
-
delimiter = options[
|
15
|
+
delimiter = options['delimiter']
|
16
16
|
|
17
17
|
path = ''
|
18
18
|
if prefix
|
@@ -45,11 +45,9 @@ module Fog
|
|
45
45
|
XmlSimple.xml_in(xml)
|
46
46
|
end
|
47
47
|
|
48
|
-
def list_multipart_uploads(bucket,
|
49
|
-
|
50
|
-
|
51
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
52
|
-
end
|
48
|
+
def list_multipart_uploads(bucket, location, _options = {})
|
49
|
+
location ||= get_bucket_location(bucket)
|
50
|
+
|
53
51
|
path = '?uploads'
|
54
52
|
resource = bucket + '/' + path
|
55
53
|
|
@@ -59,16 +57,14 @@ module Fog
|
|
59
57
|
path: path,
|
60
58
|
bucket: bucket,
|
61
59
|
resource: resource,
|
62
|
-
|
60
|
+
location: location
|
63
61
|
)
|
64
62
|
XmlSimple.xml_in(ret.data[:body])['Upload']
|
65
63
|
end
|
66
64
|
|
67
|
-
def list_parts(bucket, object,
|
68
|
-
|
69
|
-
|
70
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
71
|
-
end
|
65
|
+
def list_parts(bucket, object, location, uploadid, _options = {})
|
66
|
+
location ||= get_bucket_location(bucket)
|
67
|
+
|
72
68
|
path = object + '?uploadId=' + uploadid
|
73
69
|
resource = bucket + '/' + path
|
74
70
|
|
@@ -78,7 +74,7 @@ module Fog
|
|
78
74
|
path: path,
|
79
75
|
bucket: bucket,
|
80
76
|
resource: resource,
|
81
|
-
|
77
|
+
location: location
|
82
78
|
)
|
83
79
|
XmlSimple.xml_in(ret.data[:body])['Part']
|
84
80
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Fog
|
4
|
-
module
|
5
|
-
class
|
4
|
+
module Aliyun
|
5
|
+
class Storage
|
6
6
|
class Real
|
7
7
|
# Create a new container
|
8
8
|
#
|
@@ -12,8 +12,6 @@ module Fog
|
|
12
12
|
def put_container(name, options = {})
|
13
13
|
bucket = options[:bucket]
|
14
14
|
bucket ||= @aliyun_oss_bucket
|
15
|
-
location = get_bucket_location(bucket)
|
16
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
17
15
|
|
18
16
|
path = name + '/'
|
19
17
|
resource = bucket + '/' + name + '/'
|
@@ -23,7 +21,7 @@ module Fog
|
|
23
21
|
path: path,
|
24
22
|
bucket: bucket,
|
25
23
|
resource: resource,
|
26
|
-
|
24
|
+
location: get_bucket_location(bucket)
|
27
25
|
)
|
28
26
|
end
|
29
27
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Fog
|
4
|
-
module
|
5
|
-
class
|
4
|
+
module Aliyun
|
5
|
+
class Storage
|
6
6
|
class Real
|
7
7
|
# Put details for object
|
8
8
|
#
|
@@ -12,9 +12,7 @@ module Fog
|
|
12
12
|
def put_object(object, file = nil, options = {})
|
13
13
|
bucket = options[:bucket]
|
14
14
|
bucket ||= @aliyun_oss_bucket
|
15
|
-
|
16
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
17
|
-
return put_folder(bucket, object, endpoint) if file.nil?
|
15
|
+
return put_folder(bucket, object) if file.nil?
|
18
16
|
|
19
17
|
# put multiparts if object's size is over 100m
|
20
18
|
return put_multipart_object(bucket, object, file) if file.size > 104_857_600
|
@@ -29,15 +27,13 @@ module Fog
|
|
29
27
|
bucket: bucket,
|
30
28
|
resource: resource,
|
31
29
|
body: body,
|
32
|
-
|
30
|
+
location: get_bucket_location(bucket)
|
33
31
|
)
|
34
32
|
end
|
35
33
|
|
36
34
|
def put_object_with_body(object, body, options = {})
|
37
35
|
bucket = options[:bucket]
|
38
36
|
bucket ||= @aliyun_oss_bucket
|
39
|
-
location = get_bucket_location(bucket)
|
40
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
41
37
|
|
42
38
|
resource = bucket + '/' + object
|
43
39
|
request(
|
@@ -47,15 +43,11 @@ module Fog
|
|
47
43
|
bucket: bucket,
|
48
44
|
resource: resource,
|
49
45
|
body: body,
|
50
|
-
|
46
|
+
location: get_bucket_location(bucket)
|
51
47
|
)
|
52
48
|
end
|
53
49
|
|
54
|
-
def put_folder(bucket, folder
|
55
|
-
if endpoint.nil?
|
56
|
-
location = get_bucket_location(bucket)
|
57
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
58
|
-
end
|
50
|
+
def put_folder(bucket, folder)
|
59
51
|
path = folder + '/'
|
60
52
|
resource = bucket + '/' + folder + '/'
|
61
53
|
request(
|
@@ -64,27 +56,26 @@ module Fog
|
|
64
56
|
path: path,
|
65
57
|
bucket: bucket,
|
66
58
|
resource: resource,
|
67
|
-
|
59
|
+
location: get_bucket_location(bucket)
|
68
60
|
)
|
69
61
|
end
|
70
62
|
|
71
63
|
def put_multipart_object(bucket, object, file)
|
72
64
|
location = get_bucket_location(bucket)
|
73
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
74
65
|
|
75
66
|
# find the right uploadid
|
76
|
-
uploads = list_multipart_uploads(bucket,
|
67
|
+
uploads = list_multipart_uploads(bucket, location)
|
77
68
|
upload = (uploads&.find { |tmpupload| tmpupload['Key'][0] == object })
|
78
69
|
|
79
70
|
uploadedSize = 0
|
80
71
|
start_partNumber = 1
|
81
72
|
if !upload.nil?
|
82
73
|
uploadId = upload['UploadId'][0]
|
83
|
-
parts = list_parts(bucket, object,
|
74
|
+
parts = list_parts(bucket, object, location, uploadId)
|
84
75
|
if !parts.nil? && !parts.empty?
|
85
76
|
if parts[-1]['Size'][0].to_i != 5_242_880
|
86
77
|
# the part is the last one, if its size is over 5m, then finish this upload
|
87
|
-
complete_multipart_upload(bucket, object,
|
78
|
+
complete_multipart_upload(bucket, object, location, uploadId)
|
88
79
|
return
|
89
80
|
end
|
90
81
|
uploadedSize = (parts[0]['Size'][0].to_i * (parts.size - 1)) + parts[-1]['Size'][0].to_i
|
@@ -92,11 +83,11 @@ module Fog
|
|
92
83
|
end
|
93
84
|
else
|
94
85
|
# create upload ID
|
95
|
-
uploadId = initiate_multipart_upload(bucket, object,
|
86
|
+
uploadId = initiate_multipart_upload(bucket, object, location)
|
96
87
|
end
|
97
88
|
|
98
89
|
if file.size <= uploadedSize
|
99
|
-
complete_multipart_upload(bucket, object,
|
90
|
+
complete_multipart_upload(bucket, object, location, uploadId)
|
100
91
|
return
|
101
92
|
end
|
102
93
|
|
@@ -105,17 +96,14 @@ module Fog
|
|
105
96
|
|
106
97
|
for i in start_partNumber..end_partNumber
|
107
98
|
body = file.read(5_242_880)
|
108
|
-
upload_part(bucket, object,
|
99
|
+
upload_part(bucket, object, location, i.to_s, uploadId, body)
|
109
100
|
end
|
110
101
|
|
111
|
-
complete_multipart_upload(bucket, object,
|
102
|
+
complete_multipart_upload(bucket, object, location, uploadId)
|
112
103
|
end
|
113
104
|
|
114
|
-
def initiate_multipart_upload(bucket, object,
|
115
|
-
|
116
|
-
location = get_bucket_location(bucket)
|
117
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
118
|
-
end
|
105
|
+
def initiate_multipart_upload(bucket, object, location)
|
106
|
+
location ||= get_bucket_location(bucket)
|
119
107
|
path = object + '?uploads'
|
120
108
|
resource = bucket + '/' + path
|
121
109
|
ret = request(
|
@@ -124,16 +112,13 @@ module Fog
|
|
124
112
|
path: path,
|
125
113
|
bucket: bucket,
|
126
114
|
resource: resource,
|
127
|
-
|
115
|
+
location: location
|
128
116
|
)
|
129
117
|
XmlSimple.xml_in(ret.data[:body])['UploadId'][0]
|
130
118
|
end
|
131
119
|
|
132
|
-
def upload_part(bucket, object,
|
133
|
-
|
134
|
-
location = get_bucket_location(bucket)
|
135
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
136
|
-
end
|
120
|
+
def upload_part(bucket, object, location, partNumber, uploadId, body)
|
121
|
+
location ||= get_bucket_location(bucket)
|
137
122
|
path = object + '?partNumber=' + partNumber + '&uploadId=' + uploadId
|
138
123
|
resource = bucket + '/' + path
|
139
124
|
request(
|
@@ -143,16 +128,13 @@ module Fog
|
|
143
128
|
bucket: bucket,
|
144
129
|
resource: resource,
|
145
130
|
body: body,
|
146
|
-
|
131
|
+
location: location
|
147
132
|
)
|
148
133
|
end
|
149
134
|
|
150
|
-
def complete_multipart_upload(bucket, object,
|
151
|
-
|
152
|
-
|
153
|
-
endpoint = 'http://' + location + '.aliyuncs.com'
|
154
|
-
end
|
155
|
-
parts = list_parts(bucket, object, endpoint, uploadId, options = {})
|
135
|
+
def complete_multipart_upload(bucket, object, location, uploadId)
|
136
|
+
location ||= get_bucket_location(bucket)
|
137
|
+
parts = list_parts(bucket, object, location, uploadId, options = {})
|
156
138
|
request_part = []
|
157
139
|
return if parts.empty?
|
158
140
|
for i in 0..(parts.size - 1)
|
@@ -169,7 +151,7 @@ module Fog
|
|
169
151
|
path: path,
|
170
152
|
bucket: bucket,
|
171
153
|
resource: resource,
|
172
|
-
|
154
|
+
location: location,
|
173
155
|
body: body
|
174
156
|
)
|
175
157
|
end
|
data/lib/fog/aliyun/storage.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'xmlsimple'
|
4
|
+
require 'aliyun/oss'
|
5
|
+
|
6
|
+
# Using Aliyun OSS Ruby SDK
|
7
|
+
AliyunOssSdk= Aliyun::OSS
|
4
8
|
|
5
9
|
module Fog
|
6
|
-
module
|
7
|
-
class
|
10
|
+
module Aliyun
|
11
|
+
class Storage < Fog::Service
|
8
12
|
DEFAULT_REGION = 'cn-hangzhou'
|
9
13
|
|
10
|
-
DEFAULT_SCHEME = '
|
14
|
+
DEFAULT_SCHEME = 'https'
|
11
15
|
DEFAULT_SCHEME_PORT = {
|
12
16
|
'http' => 80,
|
13
17
|
'https' => 443
|
@@ -97,6 +101,11 @@ module Fog
|
|
97
101
|
@port = uri.port || DEFAULT_SCHEME_PORT[@scheme]
|
98
102
|
|
99
103
|
@persistent = options[:persistent] || false
|
104
|
+
@oss_client = AliyunOssSdk::Client.new(
|
105
|
+
:endpoint => @aliyun_oss_endpoint,
|
106
|
+
:access_key_id => @aliyun_accesskey_id,
|
107
|
+
:access_key_secret => @aliyun_accesskey_secret
|
108
|
+
)
|
100
109
|
end
|
101
110
|
|
102
111
|
def reload
|
@@ -118,19 +127,22 @@ module Fog
|
|
118
127
|
date = time.strftime('%a, %d %b %Y %H:%M:%S GMT')
|
119
128
|
|
120
129
|
endpoint = params[:endpoint]
|
130
|
+
location = params[:location]
|
121
131
|
if endpoint
|
122
132
|
uri = URI.parse(endpoint)
|
123
133
|
host = uri.host
|
124
134
|
path = uri.path
|
125
135
|
port = uri.port
|
126
136
|
scheme = uri.scheme
|
127
|
-
|
128
|
-
host =
|
129
|
-
path = @path
|
130
|
-
port = @port
|
131
|
-
scheme = @scheme
|
137
|
+
elsif location
|
138
|
+
host = location + '.aliyuncs.com'
|
132
139
|
end
|
133
140
|
|
141
|
+
host ||= @host
|
142
|
+
path ||= @path
|
143
|
+
port ||= @port
|
144
|
+
scheme ||= @scheme
|
145
|
+
|
134
146
|
bucket = params[:bucket]
|
135
147
|
tmpHost = if bucket
|
136
148
|
bucket + '.' + host
|
@@ -143,8 +155,10 @@ module Fog
|
|
143
155
|
|
144
156
|
begin
|
145
157
|
headers = ''
|
146
|
-
params[:headers]
|
158
|
+
if params[:headers]
|
159
|
+
params[:headers].each do |k, v|
|
147
160
|
headers += "#{k}:#{v}\n" if k != 'Range'
|
161
|
+
end
|
148
162
|
end
|
149
163
|
signature = sign(method, date, contentType, params[:resource], headers)
|
150
164
|
response = @connection.request(params.merge(headers: {
|
@@ -157,7 +171,7 @@ module Fog
|
|
157
171
|
rescue Excon::Errors::HTTPStatusError => error
|
158
172
|
raise case error
|
159
173
|
when Excon::Errors::NotFound
|
160
|
-
Fog::Storage::
|
174
|
+
Fog::Aliyun::Storage::NotFound.slurp(error)
|
161
175
|
else
|
162
176
|
error
|
163
177
|
end
|
data/lib/fog/aliyun/version.rb
CHANGED
data/lib/fog/bin/aliyun.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.11
|
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-05-
|
11
|
+
date: 2020-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,6 +100,48 @@ dependencies:
|
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: simplecov
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: memory_profiler
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: aliyun-sdk
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
103
145
|
- !ruby/object:Gem::Dependency
|
104
146
|
name: fog-core
|
105
147
|
requirement: !ruby/object:Gem::Requirement
|