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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d17874f631a07b500567d7b68ee75bccac8a68f4bb68e7a25e3be0a74dbfee9
4
- data.tar.gz: 1824454812189f3b30898eab1f902203e77494f02866a1952d8f78a9e632b4ed
3
+ metadata.gz: 91aa2154dd185e6481eff2429ffc9c04e8651764dd8d6cf196c2b689a38c461b
4
+ data.tar.gz: a7aff361e70ead42b81f2d07aff5cbb92c5dcf6624f6dbfd0e0e1e80cc888a1e
5
5
  SHA512:
6
- metadata.gz: 589b6e6590b1681ec8dc51d45cec1e631b17ecdf207625a703e677519362098b0b9101adfc4f79792d7eda9c694c4a90ed109c77c7d2af23c1fad2b1b3bb6d2f
7
- data.tar.gz: cbe9f5b1d5cc0f0b99179fd9c7aae8dec67ad9d1f5effdc7b7e86131deadf4aad51a963b061bd7c92efb52cb1fb79479db7b494ad9d9735da8fa6915f3790f3d
6
+ metadata.gz: bdc525d0d99894eb5e0dd63a6e0f4eff5fc9ebddce5c2eecbed0559010bfe25db134076d1f8a6bacc5f72d3efe4772efd02925e27481e8f3a413a6c5eb13ed01
7
+ data.tar.gz: f4726017f3fd50a33d4015adf8c1f5870645f2401acb79ab43b88fd845cef67fc838fb7a0044eed53c7007aa4ee2705819ecbe04e3f7eca3b12c78d90d6fbed8
@@ -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
- data = service.put_object(object, body, options.merge(bucket: bucket_name)).data
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
- data = service.get_bucket(directory_key)
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
- bucket_name, directory_key = check_directory_key(directory.key)
55
- remap_attributes(options, {
56
- :delimiter => 'delimiter',
57
- :marker => 'marker',
58
- :max_keys => 'max-keys',
59
- :prefix => 'prefix'
60
- })
61
- prefix_value = options['prefix']
62
- prefix_value = directory_key + '/' + prefix if directory_key != '' && directory_key != '.' && !directory_key.nil?
63
- options['prefix'] = prefix_value
64
- options['bucket'] = bucket_name
65
- files = service.list_objects(options)['Contents']
66
- return if files.nil?
67
- data = []
68
- i = 0
69
- files.each do |file|
70
- next unless file['Key'][0][-1] != '/'
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
@@ -25,8 +25,7 @@ module Fog
25
25
  method: 'PUT',
26
26
  path: target_object,
27
27
  bucket: target_bucket,
28
- resource: resource,
29
- location: get_bucket_location(bucket))
28
+ resource: resource)
30
29
  end
31
30
  end
32
31
  end
@@ -15,8 +15,7 @@ module Fog
15
15
  expects: 204,
16
16
  method: 'DELETE',
17
17
  bucket: bucket,
18
- resource: resource,
19
- location: get_bucket_location(bucket)
18
+ resource: resource
20
19
  )
21
20
  end
22
21
  end
@@ -21,8 +21,7 @@ module Fog
21
21
  method: 'DELETE',
22
22
  path: object,
23
23
  bucket: bucket,
24
- resource: resource,
25
- location: get_bucket_location(bucket)
24
+ resource: resource
26
25
  )
27
26
  end
28
27
  end
@@ -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
@@ -38,7 +38,6 @@ module Fog
38
38
  path += '?delimiter=' + delimiter
39
39
  end
40
40
 
41
- location = get_bucket_location(bucket)
42
41
  resource = bucket + '/'
43
42
  ret = request(
44
43
  expects: [200, 203, 400],
@@ -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
- bucket = options[:bucket]
20
- bucket ||= @aliyun_oss_bucket
21
- acl = get_bucket_acl(bucket)
22
- location = get_bucket_location(bucket)
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 = bucket + '/' + object
26
+ resource = bucket_name + '/' + object
27
27
  signature = sign('GET', expires_time, nil, resource)
28
- 'http://' + bucket + '.' + location + '.aliyuncs.com/' + object +
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://' + bucket + '.' + location + '.aliyuncs.com/' + object
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
- bucket = options[:bucket]
20
- bucket ||= @aliyun_oss_bucket
21
- acl = get_bucket_acl(bucket)
22
- location = get_bucket_location(bucket)
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 = bucket + '/' + object
26
+ resource = bucket_name + '/' + object
27
27
  signature = sign('GET', expires_time, nil, resource)
28
- 'https://' + bucket + '.' + location + '.aliyuncs.com/' + object +
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://' + bucket + '.' + location + '.aliyuncs.com/' + object
32
+ 'https://' + bucket_name + '.' + @host + '/' + object
33
33
  else
34
34
  'acl is wrong with value:' + acl
35
35
  end
@@ -18,8 +18,7 @@ module Fog
18
18
  method: 'HEAD',
19
19
  path: object,
20
20
  bucket: bucket,
21
- resource: resource,
22
- location: get_bucket_location(bucket)
21
+ resource: resource
23
22
  )
24
23
  ret
25
24
  end
@@ -45,9 +45,7 @@ module Fog
45
45
  XmlSimple.xml_in(xml)
46
46
  end
47
47
 
48
- def list_multipart_uploads(bucket, location, _options = {})
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, location, uploadid, _options = {})
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
@@ -20,8 +20,7 @@ module Fog
20
20
  method: 'PUT',
21
21
  path: path,
22
22
  bucket: bucket,
23
- resource: resource,
24
- location: get_bucket_location(bucket)
23
+ resource: resource
25
24
  )
26
25
  end
27
26
  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
- bucket = options[:bucket]
14
- bucket ||= @aliyun_oss_bucket
15
- return put_folder(bucket, object) if file.nil?
16
-
17
- # put multiparts if object's size is over 100m
18
- return put_multipart_object(bucket, object, file) if file.size > 104_857_600
19
-
20
- body = file.read
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
- bucket = options[:bucket]
36
- bucket ||= @aliyun_oss_bucket
25
+ bucket_name = options[:bucket]
26
+ bucket_name ||= @aliyun_oss_bucket
37
27
 
38
- resource = bucket + '/' + object
28
+ resource = bucket_name + '/' + object
39
29
  request(
40
30
  expects: [200, 203],
41
31
  method: 'PUT',
42
32
  path: object,
43
- bucket: 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, location)
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, location, uploadId)
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, location, uploadId)
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, location)
72
+ uploadId = initiate_multipart_upload(bucket, object)
87
73
  end
88
74
 
89
75
  if file.size <= uploadedSize
90
- complete_multipart_upload(bucket, object, location, uploadId)
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, location, i.to_s, uploadId, body)
85
+ upload_part(bucket, object, i.to_s, uploadId, body)
100
86
  end
101
87
 
102
- complete_multipart_upload(bucket, object, location, uploadId)
88
+ complete_multipart_upload(bucket, object, uploadId)
103
89
  end
104
90
 
105
- def initiate_multipart_upload(bucket, object, location)
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, location, partNumber, uploadId, body)
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, location, uploadId)
136
- location ||= get_bucket_location(bucket)
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
@@ -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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fog
4
4
  module Aliyun
5
- VERSION = '0.3.15'
5
+ VERSION = '0.3.16'
6
6
  end
7
7
  end
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.15
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-05 00:00:00.000000000 Z
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