aws-sdk-s3 1.74.0 → 1.75.0

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: 626495d85d0f33f1a04615e2c65aca4331f8ac04b35306d2e68668eb1cbad727
4
- data.tar.gz: 324b43984913dedda5bd63af0608eb9ba01feab28e8ff15ee5ceb7b1cb5d5578
3
+ metadata.gz: 75f8d275e892e31dfb80d004f49fb465fc4388e92f20e2827089d5dc76e0d821
4
+ data.tar.gz: 1f84cba631bb2e6a81d07ea671fec120d6bf33dcbfe6e427de26444c36627cf8
5
5
  SHA512:
6
- metadata.gz: f4958752f8508e3d4ecdb0ad22bc5184f3c9e8c9c6e035bfcb5cabda3897fb8fec2b3da206499689f400c001e83e1d364daeea687bff71cbcc1b910779936058
7
- data.tar.gz: ef54aeb2dc6373afe0b806a4e88ca85ed81eedba190da89c7370d10eea5535f6f608ba80539b7c5b31f3198ab64767afda81c8560475c9268155af373e1d23ff
6
+ metadata.gz: f034970098a597fd9d6eeb87a8a82c1ed30ff918ca292b1a0a3f380f08e5b8f504ec619b1763312720f1b28e1df6ba7b56c0bac19dc09c9923bc21aa8be189d1
7
+ data.tar.gz: 0bb581e24c1e3d0fa6306c574146f7ef1e85ff949911d7917c0f4cf8cf85b364cf8b0210ed2ba54a85ec5838a463368ede8f978846e123f79f78e92e3fffd4c9
@@ -68,6 +68,6 @@ require_relative 'aws-sdk-s3/event_streams'
68
68
  # @service
69
69
  module Aws::S3
70
70
 
71
- GEM_VERSION = '1.74.0'
71
+ GEM_VERSION = '1.75.0'
72
72
 
73
73
  end
@@ -4589,8 +4589,10 @@ module Aws::S3
4589
4589
  #
4590
4590
  # @example Streaming data to a block
4591
4591
  # # WARNING: yielding data to a block disables retries of networking errors
4592
+ # # However truncation of the body will be retried automatically using a range request
4592
4593
  # File.open('/path/to/file', 'wb') do |file|
4593
- # s3.get_object(bucket: 'bucket-name', key: 'object-key') do |chunk|
4594
+ # s3.get_object(bucket: 'bucket-name', key: 'object-key') do |chunk, headers|
4595
+ # # headers['content-length']
4594
4596
  # file.write(chunk)
4595
4597
  # end
4596
4598
  # end
@@ -11672,7 +11674,7 @@ module Aws::S3
11672
11674
  params: params,
11673
11675
  config: config)
11674
11676
  context[:gem_name] = 'aws-sdk-s3'
11675
- context[:gem_version] = '1.74.0'
11677
+ context[:gem_version] = '1.75.0'
11676
11678
  Seahorse::Client::Request.new(handlers, context)
11677
11679
  end
11678
11680
 
@@ -296,6 +296,14 @@ module Aws
296
296
  # etag = response.etag
297
297
  # end
298
298
  #
299
+ # You can provide a callback to monitor progress of the upload:
300
+ #
301
+ # # bytes and totals are each an array with 1 entry per part
302
+ # progress = Proc.new do |bytes, totals|
303
+ # puts bytes.map.with_index { |b, i| "Part #{i+1}: #{b} / #{totals[i]}"}.join(' ') + "Total: #{100.0 * bytes.sum / totals.sum }%" }
304
+ # end
305
+ # obj.upload_file('/path/to/file')
306
+ #
299
307
  # @param [String, Pathname, File, Tempfile] source A file on the local
300
308
  # file system that will be uploaded as this object. This can either be
301
309
  # a String or Pathname to the file, an open File object, or an open
@@ -312,6 +320,10 @@ module Aws
312
320
  # multipart uploads. This option is not used if the file is smaller than
313
321
  # `:multipart_threshold`.
314
322
  #
323
+ # @option options [Proc] :progress_callback
324
+ # A Proc that will be called when each chunk of the upload is sent.
325
+ # It will be invoked with [bytes_read], [total_sizes]
326
+ #
315
327
  # @raise [MultipartUploadError] If an object is being uploaded in
316
328
  # parts, and the upload can not be completed, then the upload is
317
329
  # aborted and this error is raised. The raised error has a `#errors`
@@ -320,7 +332,6 @@ module Aws
320
332
  #
321
333
  # @return [Boolean] Returns `true` when the object is uploaded
322
334
  # without any errors.
323
- #
324
335
  def upload_file(source, options = {})
325
336
  uploading_options = options.dup
326
337
  uploader = FileUploader.new(
@@ -29,6 +29,9 @@ module Aws
29
29
  # @param [String, Pathname, File, Tempfile] source The file to upload.
30
30
  # @option options [required, String] :bucket The bucket to upload to.
31
31
  # @option options [required, String] :key The key for the object.
32
+ # @option options [Proc] :progress_callback
33
+ # A Proc that will be called when each chunk of the upload is sent.
34
+ # It will be invoked with [bytes_read], [total_sizes]
32
35
  # @return [void]
33
36
  def upload(source, options = {})
34
37
  if File.size(source) >= multipart_threshold
@@ -49,11 +52,19 @@ module Aws
49
52
  end
50
53
 
51
54
  def put_object(source, options)
55
+ if (callback = options.delete(:progress_callback))
56
+ options[:on_chunk_sent] = single_part_progress(callback)
57
+ end
52
58
  open_file(source) do |file|
53
59
  @client.put_object(options.merge(body: file))
54
60
  end
55
61
  end
56
62
 
63
+ def single_part_progress(progress_callback)
64
+ proc do |_chunk, bytes_read, total_size|
65
+ progress_callback.call([bytes_read], [total_size])
66
+ end
67
+ end
57
68
  end
58
69
  end
59
70
  end
@@ -39,6 +39,9 @@ module Aws
39
39
  # @param [String, Pathname, File, Tempfile] source The file to upload.
40
40
  # @option options [required, String] :bucket The bucket to upload to.
41
41
  # @option options [required, String] :key The key for the object.
42
+ # @option options [Proc] :progress_callback
43
+ # A Proc that will be called when each chunk of the upload is sent.
44
+ # It will be invoked with [bytes_read], [total_sizes]
42
45
  # @return [void]
43
46
  def upload(source, options = {})
44
47
  if File.size(source) < MIN_PART_SIZE
@@ -68,7 +71,7 @@ module Aws
68
71
  def upload_parts(upload_id, source, options)
69
72
  pending = PartList.new(compute_parts(upload_id, source, options))
70
73
  completed = PartList.new
71
- errors = upload_in_threads(pending, completed)
74
+ errors = upload_in_threads(pending, completed, options)
72
75
  if errors.empty?
73
76
  completed.to_a.sort_by { |part| part[:part_number] }
74
77
  else
@@ -127,12 +130,21 @@ module Aws
127
130
  end
128
131
  end
129
132
 
130
- def upload_in_threads(pending, completed)
133
+ def upload_in_threads(pending, completed, options)
131
134
  threads = []
135
+ if (callback = options[:progress_callback])
136
+ progress = MultipartProgress.new(pending, callback)
137
+ end
132
138
  @thread_count.times do
133
139
  thread = Thread.new do
134
140
  begin
135
141
  while part = pending.shift
142
+ if progress
143
+ part[:on_chunk_sent] =
144
+ proc do |_chunk, bytes, _total|
145
+ progress.call(part[:part_number], bytes)
146
+ end
147
+ end
136
148
  resp = @client.upload_part(part)
137
149
  part[:body].close
138
150
  completed.push(etag: resp.etag, part_number: part[:part_number])
@@ -182,11 +194,34 @@ module Aws
182
194
  @mutex.synchronize { @parts.clear }
183
195
  end
184
196
 
197
+ def size
198
+ @mutex.synchronize { @parts.size }
199
+ end
200
+
201
+ def part_sizes
202
+ @mutex.synchronize { @parts.map { |p| p[:body].size } }
203
+ end
204
+
185
205
  def to_a
186
206
  @mutex.synchronize { @parts.dup }
187
207
  end
188
208
 
189
209
  end
210
+
211
+ # @api private
212
+ class MultipartProgress
213
+ def initialize(parts, progress_callback)
214
+ @bytes_sent = Array.new(parts.size, 0)
215
+ @total_sizes = parts.part_sizes
216
+ @progress_callback = progress_callback
217
+ end
218
+
219
+ def call(part_number, bytes_read)
220
+ # part numbers start at 1
221
+ @bytes_sent[part_number - 1] = bytes_read
222
+ @progress_callback.call(@bytes_sent, @total_sizes)
223
+ end
224
+ end
190
225
  end
191
226
  end
192
227
  end
@@ -37,7 +37,9 @@ each bucket. [Go here for more information](http://docs.aws.amazon.com/AmazonS3/
37
37
  class OptionHandler < Seahorse::Client::Handler
38
38
  def call(context)
39
39
  # Support client configuration and per-operation configuration
40
- accelerate = context.params.delete(:use_accelerate_endpoint)
40
+ if context.params.is_a?(Hash)
41
+ accelerate = context.params.delete(:use_accelerate_endpoint)
42
+ end
41
43
  if accelerate.nil?
42
44
  accelerate = context.config.use_accelerate_endpoint
43
45
  end
@@ -22,7 +22,9 @@ for all operations.
22
22
  # @api private
23
23
  class OptionHandler < Seahorse::Client::Handler
24
24
  def call(context)
25
- dualstack = context.params.delete(:use_dualstack_endpoint)
25
+ if context.params.is_a?(Hash)
26
+ dualstack = context.params.delete(:use_dualstack_endpoint)
27
+ end
26
28
  dualstack = context.config.use_dualstack_endpoint if dualstack.nil?
27
29
  context[:use_dualstack_endpoint] = dualstack
28
30
  @handler.call(context)
@@ -20,7 +20,7 @@ This should only be disabled for local testing.
20
20
  class Handler < Seahorse::Client::Handler
21
21
 
22
22
  def call(context)
23
- compute_key_md5(context)
23
+ compute_key_md5(context) if context.params.is_a?(Hash)
24
24
  @handler.call(context)
25
25
  end
26
26
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.74.0
4
+ version: 1.75.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-08 00:00:00.000000000 Z
11
+ date: 2020-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-kms
@@ -47,7 +47,7 @@ dependencies:
47
47
  version: '3'
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: 3.102.1
50
+ version: 3.104.1
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -57,7 +57,7 @@ dependencies:
57
57
  version: '3'
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 3.102.1
60
+ version: 3.104.1
61
61
  description: Official AWS Ruby gem for Amazon Simple Storage Service (Amazon S3).
62
62
  This gem is part of the AWS SDK for Ruby.
63
63
  email: