fog-aliyun 0.3.16 → 0.3.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91aa2154dd185e6481eff2429ffc9c04e8651764dd8d6cf196c2b689a38c461b
4
- data.tar.gz: a7aff361e70ead42b81f2d07aff5cbb92c5dcf6624f6dbfd0e0e1e80cc888a1e
3
+ metadata.gz: 7e69954ae4115e7137286fe738da6423b1898a522f463ac65526ca4c692ce40e
4
+ data.tar.gz: 991d52c7f3688fc0417b037266480f800f189a9de8d0af421d139829ddde6121
5
5
  SHA512:
6
- metadata.gz: bdc525d0d99894eb5e0dd63a6e0f4eff5fc9ebddce5c2eecbed0559010bfe25db134076d1f8a6bacc5f72d3efe4772efd02925e27481e8f3a413a6c5eb13ed01
7
- data.tar.gz: f4726017f3fd50a33d4015adf8c1f5870645f2401acb79ab43b88fd845cef67fc838fb7a0044eed53c7007aa4ee2705819ecbe04e3f7eca3b12c78d90d6fbed8
6
+ metadata.gz: 6a53c7749c71417451ae19d72834c3cabfa8f6a13fe4a68f0c1c05515429444c799ccc410241cfbbbfdebbe3b51496a35607f25869eebb09d2b99d9325114a4c
7
+ data.tar.gz: 165d735915b2cf6e7887a0f5b5205afef604bfa6d6c9bdc5471203811d6c1f4d19ca6fcd45388a01672983e6c03489354c99745e1376f0da9015334f68133b85
@@ -1,4 +1,30 @@
1
1
  ## 0.3.17 (Unreleased)
2
+ ## 0.3.17 (July 06, 2020)
3
+
4
+ IMPROVEMENTS:
5
+ - adater oss_sdk_log_path [GH-125](https://github.com/fog/fog-aliyun/pull/125)
6
+ - update ruby sdk to 0.7.3 [GH-124](https://github.com/fog/fog-aliyun/pull/124)
7
+ - adapter maxkeys conversion problem [GH-123](https://github.com/fog/fog-aliyun/pull/123)
8
+ - [Enhance tests][Auth & Connectivity scenarios] Test that API cannot be accessed using incorrect credentials [GH-117](https://github.com/fog/fog-aliyun/pull/117)
9
+ - [Enhance tests][Auth & Connectivity scenarios] Test that API can be accessed using valid credentials [GH-116](https://github.com/fog/fog-aliyun/pull/116)
10
+ - adapter custom log environment variable [GH-114](https://github.com/fog/fog-aliyun/pull/114)
11
+ - [Enhance tests][Buckets scenarios] (NEGATIVE TEST) Test that error is thrown when trying to access non-existing bucket [GH-110](https://github.com/fog/fog-aliyun/pull/110)
12
+ - [Enhance tests][Buckets scenarios] (NEGATIVE TEST) Test that error is thrown when trying to create already existing bucket [GH-109](https://github.com/fog/fog-aliyun/pull/109)
13
+ - [Enhance tests][Buckets scenarios] Test that it is possible to destroy a bucket [GH-108](https://github.com/fog/fog-aliyun/pull/108)
14
+ - [Enhance tests][Buckets scenarios] Test that it is possible to create a new bucket [GH-107](https://github.com/fog/fog-aliyun/pull/107)
15
+ - [Enhance tests][Buckets scenarios] Test that it is possible to list all buckets [GH-105](https://github.com/fog/fog-aliyun/pull/105)
16
+ - [Enhance tests][Files & Directory scenarios] Test getting bucket when directory exists named with the same name as a bucket [GH-101](https://github.com/fog/fog-aliyun/pull/101)
17
+ - [Enhance tests][Files & Directory scenarios] Test file copy operations [GH-100](https://github.com/fog/fog-aliyun/pull/100)
18
+ - reset the last PR [GH-133](https://github.com/fog/fog-aliyun/pull/133)
19
+ - improve put_object_with_body and head_object using sdk do_request [GH-131](https://github.com/fog/fog-aliyun/pull/131)
20
+
21
+ BUG FIXES:
22
+ - fix max key again [GH-128](https://github.com/fog/fog-aliyun/pull/128)
23
+ - fix downloading object when pushing app twice [GH-127](https://github.com/fog/fog-aliyun/pull/127)
24
+ - fix max key [GH-126](https://github.com/fog/fog-aliyun/pull/126)
25
+ - fix max-keys conversion problem [GH-121](https://github.com/fog/fog-aliyun/pull/121)
26
+ - fix @aliyun_oss_sdk_log_path is nil [GH-132](https://github.com/fog/fog-aliyun/pull/132)
27
+
2
28
  ## 0.3.16 (June 18, 2020)
3
29
 
4
30
  IMPROVEMENTS:
@@ -28,9 +28,9 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'rubocop'
29
29
  spec.add_development_dependency 'simplecov'
30
30
  spec.add_development_dependency 'memory_profiler'
31
- spec.add_development_dependency 'aliyun-sdk', '~> 0.7.2'
31
+ spec.add_development_dependency 'aliyun-sdk', '~> 0.7.3'
32
32
 
33
- spec.add_dependency 'aliyun-sdk', '~> 0.7.2'
33
+ spec.add_dependency 'aliyun-sdk', '~> 0.7.3'
34
34
  spec.add_dependency 'fog-core'
35
35
  spec.add_dependency 'fog-json'
36
36
  spec.add_dependency 'ipaddress', '~> 0.8'
@@ -85,7 +85,7 @@ module Fog
85
85
  end
86
86
  end
87
87
 
88
- def get(key)
88
+ def get(key, options = {}, &block)
89
89
  requires :directory
90
90
  bucket_name, directory_key = check_directory_key(directory.key)
91
91
  object = if directory_key == ''
@@ -94,24 +94,25 @@ module Fog
94
94
  directory_key + '/' + key
95
95
  end
96
96
  begin
97
- data = service.get_object(object, nil, bucket: bucket_name)
98
- lastModified = data['headers'][:last_modified]
97
+ data = service.get_object(object, options.merge({bucket: bucket_name}), &block)
98
+ headers = data.headers
99
+ lastModified = headers[:last_modified]
99
100
  last_modified = (Time.parse(lastModified).localtime if !lastModified.nil? && lastModified != '')
100
101
 
101
- date = data['headers'][:date]
102
+ date = headers[:date]
102
103
  date = (Time.parse(date).localtime if !date.nil? && date != '')
103
104
  file_data = {
104
- body: data[:body],
105
- content_length: data['headers'][:content_length].to_i,
105
+ body: data.body,
106
+ content_length: headers[:content_length].to_i,
106
107
  key: key,
107
108
  last_modified: last_modified,
108
- content_type: data['headers'][:content_type],
109
- etag: data['headers'][:etag],
109
+ content_type: headers[:content_type],
110
+ etag: headers[:etag],
110
111
  date: date,
111
- connection: data['headers'][:connection],
112
- accept_ranges: data['headers'][:accept_ranges],
113
- server: data['headers'][:server],
114
- object_type: data['headers'][:x_oss_object_type]
112
+ connection: headers[:connection],
113
+ accept_ranges: headers[:accept_ranges],
114
+ server: headers[:server],
115
+ object_type: headers[:x_oss_object_type]
115
116
  }
116
117
 
117
118
  new(file_data)
@@ -13,22 +13,23 @@ module Fog
13
13
  marker = options['marker']
14
14
  # Set the GetBucket max limitation to 1000
15
15
  maxKeys = options['max-keys'] || 1000
16
- maxKeys = [maxKeys, 1000].min
16
+ maxKeys = maxKeys.to_i
17
+ maxKeys = [maxKeys, 1000].min.to_s
17
18
  delimiter = options['delimiter']
18
19
  path = ''
19
20
  if prefix
20
21
  path += '/?prefix=' + prefix
21
22
  path += '&marker=' + marker if marker
22
- path += '&max-keys=' + maxKeys.to_s if maxKeys
23
+ path += '&max-keys=' + maxKeys if maxKeys
23
24
  path += '&delimiter=' + delimiter if delimiter
24
25
 
25
26
  elsif marker
26
27
  path += '/?marker=' + marker
27
- path += '&max-keys=' + maxKeys.to_s if maxKeys
28
+ path += '&max-keys=' + maxKeys if maxKeys
28
29
  path += '&delimiter=' + delimiter if delimiter
29
30
 
30
31
  elsif maxKeys
31
- path += '/?max-keys=' + maxKeys.to_s
32
+ path += '/?max-keys=' + maxKeys
32
33
  path += '&delimiter=' + delimiter if delimiter
33
34
  elsif delimiter
34
35
  path += '/?delimiter=' + delimiter
@@ -11,7 +11,9 @@ module Fog
11
11
  bucket ||= @aliyun_oss_bucket
12
12
 
13
13
  marker = options[:marker]
14
- maxKeys = options[:maxKeys]
14
+ maxKeys = options[:maxKeys]||1000
15
+ maxKeys = maxKeys.to_i
16
+ maxKeys = [maxKeys,1000].min.to_s
15
17
  delimiter = '/'
16
18
 
17
19
  path = ''
@@ -19,7 +19,9 @@ module Fog
19
19
  bucket ||= @aliyun_oss_bucket
20
20
  prefix = options[:prefix]
21
21
  marker = options[:marker]
22
- maxKeys = options[:maxKeys]
22
+ maxKeys = options[:maxKeys]||1000
23
+ maxKeys = maxKeys.to_i
24
+ maxKeys = [maxKeys,1000].min.to_s
23
25
  delimiter = '/'
24
26
 
25
27
  path = ''
@@ -9,19 +9,29 @@ module Fog
9
9
  # ==== Parameters
10
10
  # * object<~String> - Name of object to look for
11
11
  #
12
- def get_object(object, range = nil, options = {})
12
+ def get_object(object, options = {}, &block)
13
13
  options = options.reject { |_key, value| value.nil? }
14
14
  bucket_name = options[:bucket]
15
15
  bucket_name ||= @aliyun_oss_bucket
16
+ options.delete(:bucket)
16
17
  # 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
18
+ params = { :headers => {} }
19
+ params[:query] = options.delete('query') || {}
20
+
21
+ params[:headers].merge!(options)
22
+ if options['If-Modified-Since']
23
+ params[:headers]['If-Modified-Since'] = Fog::Time.at(options['If-Modified-Since'].to_i).to_date_header
24
+ end
25
+ if options['If-Unmodified-Since']
26
+ params[:headers]['If-Unmodified-Since'] = Fog::Time.at(options['If-Unmodified-Since'].to_i).to_date_header
27
+ end
28
+
29
+ if block_given?
30
+ params[:response_block] = Proc.new
21
31
  end
22
- response = {}
23
- obj.instance_variables.each {|var| response[var.to_s.delete("@")] = obj.instance_variable_get(var) }
24
- response.merge({:body => body.join('')})
32
+
33
+ @oss_http.get({:bucket => bucket_name, :object => object}, params, &block)
34
+
25
35
  end
26
36
  end
27
37
  end
@@ -10,14 +10,14 @@ module Fog
10
10
  # * object<~String> - Name of object to look for
11
11
  #
12
12
  def head_object(object, options = {})
13
- bucket = options[:bucket]
14
- bucket ||= @aliyun_oss_bucket
15
- resource = bucket + '/' + object
13
+ bucket_name = options[:bucket]
14
+ bucket_name ||= @aliyun_oss_bucket
15
+ resource = bucket_name + '/' + object
16
16
  ret = request(
17
17
  expects: [200, 404],
18
18
  method: 'HEAD',
19
19
  path: object,
20
- bucket: bucket,
20
+ bucket: bucket_name,
21
21
  resource: resource
22
22
  )
23
23
  ret
@@ -7,7 +7,9 @@ module Fog
7
7
  def list_buckets(options = {})
8
8
  prefix = options[:prefix]
9
9
  marker = options[:marker]
10
- maxKeys = options[:maxKeys]
10
+ maxKeys = options[:maxKeys] || 1000
11
+ maxKeys = maxKeys.to_i
12
+ maxKeys =[maxKeys,1000].min.to_s
11
13
 
12
14
  path = ''
13
15
  if prefix
@@ -10,24 +10,25 @@ module Fog
10
10
  prefix = options['prefix']
11
11
  marker = options['marker']
12
12
  # Set the ListObjects max limitation to 1000
13
- maxKeys = options['max-keys'] || 1000
14
- maxKeys = [maxKeys, 1000].min
13
+ maxKeys = options[:maxKeys]||1000
14
+ maxKeys = maxKeys.to_i
15
+ maxKeys = [maxKeys,1000].min.to_s
15
16
  delimiter = options['delimiter']
16
17
 
17
18
  path = ''
18
19
  if prefix
19
20
  path += '/?prefix=' + prefix
20
21
  path += '&marker=' + marker if marker
21
- path += '&max-keys=' + maxKeys.to_s if maxKeys
22
+ path += '&max-keys=' + maxKeys if maxKeys
22
23
  path += '&delimiter=' + delimiter if delimiter
23
24
 
24
25
  elsif marker
25
26
  path += '/?marker=' + marker
26
- path += '&max-keys=' + maxKeys.to_s if maxKeys
27
+ path += '&max-keys=' + maxKeys if maxKeys
27
28
  path += '&delimiter=' + delimiter if delimiter
28
29
 
29
30
  elsif maxKeys
30
- path += '/?max-keys=' + maxKeys.to_s
31
+ path += '/?max-keys=' + maxKeys
31
32
  path += '&delimiter=' + delimiter if delimiter
32
33
  elsif delimiter
33
34
  path += '/?delimiter=' + delimiter
@@ -19,7 +19,9 @@ module Fog
19
19
 
20
20
  recognizes :aliyun_oss_endpoint,
21
21
  :aliyun_oss_location,
22
- :aliyun_region_id
22
+ :aliyun_region_id,
23
+ :aliyun_oss_sdk_log_path
24
+
23
25
  requires :aliyun_accesskey_id,
24
26
  :aliyun_accesskey_secret,
25
27
  :aliyun_oss_bucket
@@ -72,6 +74,7 @@ module Fog
72
74
  attr_reader :aliyun_oss_endpoint
73
75
  attr_reader :aliyun_region_id
74
76
  attr_reader :aliyun_oss_bucket
77
+ attr_reader :aliyun_oss_sdk_log_path
75
78
 
76
79
  def initialize(options = {})
77
80
  # initialize the parameters
@@ -80,7 +83,11 @@ module Fog
80
83
  @aliyun_accesskey_id = options[:aliyun_accesskey_id]
81
84
  @aliyun_accesskey_secret = options[:aliyun_accesskey_secret]
82
85
  @aliyun_oss_bucket = options[:aliyun_oss_bucket]
83
-
86
+ @aliyun_oss_sdk_log_path=options[:aliyun_oss_sdk_log_path]
87
+ if @aliyun_oss_sdk_log_path && !::File.exist?(@aliyun_oss_sdk_log_path)
88
+ `touch #{@aliyun_oss_sdk_log_path}`
89
+ end
90
+ ENV["ALIYUN_OSS_SDK_LOG_PATH"] = @aliyun_oss_sdk_log_path
84
91
  # check for the parameters
85
92
  missing_credentials = []
86
93
  missing_credentials << :aliyun_oss_bucket unless @aliyun_oss_bucket
@@ -106,6 +113,14 @@ module Fog
106
113
  :access_key_id => @aliyun_accesskey_id,
107
114
  :access_key_secret => @aliyun_accesskey_secret
108
115
  )
116
+
117
+ # initiate a aliyun oss ruby sdk config and using sdk http to invoke the OSS openapi
118
+ @oss_config = AliyunOssSdk::Config.new(
119
+ :endpoint => @aliyun_oss_endpoint,
120
+ :access_key_id => @aliyun_accesskey_id,
121
+ :access_key_secret => @aliyun_accesskey_secret
122
+ )
123
+ @oss_http = AliyunOssSdk::HTTP.new(@oss_config)
109
124
  end
110
125
 
111
126
  def reload
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fog
4
4
  module Aliyun
5
- VERSION = '0.3.16'
5
+ VERSION = '0.3.17'
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.16
4
+ version: 0.3.17
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-17 00:00:00.000000000 Z
11
+ date: 2020-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -134,28 +134,28 @@ dependencies:
134
134
  requirements:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: 0.7.2
137
+ version: 0.7.3
138
138
  type: :development
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: 0.7.2
144
+ version: 0.7.3
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: aliyun-sdk
147
147
  requirement: !ruby/object:Gem::Requirement
148
148
  requirements:
149
149
  - - "~>"
150
150
  - !ruby/object:Gem::Version
151
- version: 0.7.2
151
+ version: 0.7.3
152
152
  type: :runtime
153
153
  prerelease: false
154
154
  version_requirements: !ruby/object:Gem::Requirement
155
155
  requirements:
156
156
  - - "~>"
157
157
  - !ruby/object:Gem::Version
158
- version: 0.7.2
158
+ version: 0.7.3
159
159
  - !ruby/object:Gem::Dependency
160
160
  name: fog-core
161
161
  requirement: !ruby/object:Gem::Requirement