aws-sdk-s3 1.119.1 → 1.132.1

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +97 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-s3/bucket.rb +108 -55
  5. data/lib/aws-sdk-s3/bucket_acl.rb +9 -3
  6. data/lib/aws-sdk-s3/bucket_cors.rb +12 -4
  7. data/lib/aws-sdk-s3/bucket_lifecycle.rb +12 -4
  8. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +12 -4
  9. data/lib/aws-sdk-s3/bucket_logging.rb +9 -3
  10. data/lib/aws-sdk-s3/bucket_notification.rb +9 -3
  11. data/lib/aws-sdk-s3/bucket_policy.rb +12 -4
  12. data/lib/aws-sdk-s3/bucket_request_payment.rb +9 -3
  13. data/lib/aws-sdk-s3/bucket_tagging.rb +12 -4
  14. data/lib/aws-sdk-s3/bucket_versioning.rb +15 -5
  15. data/lib/aws-sdk-s3/bucket_website.rb +12 -4
  16. data/lib/aws-sdk-s3/client.rb +1740 -1441
  17. data/lib/aws-sdk-s3/client_api.rb +24 -0
  18. data/lib/aws-sdk-s3/customizations/bucket.rb +3 -1
  19. data/lib/aws-sdk-s3/customizations/errors.rb +27 -0
  20. data/lib/aws-sdk-s3/customizations/object.rb +49 -18
  21. data/lib/aws-sdk-s3/customizations/types/permanent_redirect.rb +26 -0
  22. data/lib/aws-sdk-s3/customizations.rb +2 -0
  23. data/lib/aws-sdk-s3/encryption/client.rb +6 -2
  24. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +13 -9
  25. data/lib/aws-sdk-s3/encryptionV2/client.rb +6 -2
  26. data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +1 -0
  27. data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +10 -6
  28. data/lib/aws-sdk-s3/endpoint_parameters.rb +4 -0
  29. data/lib/aws-sdk-s3/endpoint_provider.rb +103 -327
  30. data/lib/aws-sdk-s3/endpoints.rb +1 -0
  31. data/lib/aws-sdk-s3/file_downloader.rb +61 -25
  32. data/lib/aws-sdk-s3/file_uploader.rb +8 -6
  33. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +5 -3
  34. data/lib/aws-sdk-s3/multipart_upload.rb +12 -4
  35. data/lib/aws-sdk-s3/multipart_upload_part.rb +10 -4
  36. data/lib/aws-sdk-s3/object.rb +105 -77
  37. data/lib/aws-sdk-s3/object_acl.rb +9 -3
  38. data/lib/aws-sdk-s3/object_copier.rb +7 -5
  39. data/lib/aws-sdk-s3/object_multipart_copier.rb +33 -17
  40. data/lib/aws-sdk-s3/object_summary.rb +103 -64
  41. data/lib/aws-sdk-s3/object_version.rb +35 -9
  42. data/lib/aws-sdk-s3/plugins/s3_signer.rb +13 -11
  43. data/lib/aws-sdk-s3/presigned_post.rb +52 -43
  44. data/lib/aws-sdk-s3/presigner.rb +4 -2
  45. data/lib/aws-sdk-s3/resource.rb +7 -3
  46. data/lib/aws-sdk-s3/types.rb +711 -405
  47. data/lib/aws-sdk-s3.rb +1 -1
  48. metadata +8 -6
@@ -9,6 +9,7 @@
9
9
 
10
10
 
11
11
  module Aws::S3
12
+ # @api private
12
13
  module Endpoints
13
14
 
14
15
  class AbortMultipartUpload
@@ -32,39 +32,66 @@ module Aws
32
32
  }
33
33
  @params[:version_id] = options[:version_id] if options[:version_id]
34
34
 
35
- case @mode
36
- when 'auto' then multipart_download
37
- when 'single_request' then single_request
38
- when 'get_range'
39
- if @chunk_size
40
- resp = @client.head_object(@params)
41
- multithreaded_get_by_ranges(construct_chunks(resp.content_length))
35
+ # checksum_mode only supports the value "ENABLED"
36
+ # falsey values (false/nil) or "DISABLED" should be considered
37
+ # disabled and the api parameter should be unset.
38
+ if (checksum_mode = options.fetch(:checksum_mode, 'ENABLED'))
39
+ @params[:checksum_mode] = checksum_mode unless checksum_mode.upcase == 'DISABLED'
40
+ end
41
+ @on_checksum_validated = options[:on_checksum_validated]
42
+
43
+ validate!
44
+
45
+ Aws::Plugins::UserAgent.feature('s3-transfer') do
46
+ case @mode
47
+ when 'auto' then multipart_download
48
+ when 'single_request' then single_request
49
+ when 'get_range'
50
+ if @chunk_size
51
+ resp = @client.head_object(@params)
52
+ multithreaded_get_by_ranges(construct_chunks(resp.content_length))
53
+ else
54
+ msg = 'In :get_range mode, :chunk_size must be provided'
55
+ raise ArgumentError, msg
56
+ end
42
57
  else
43
- msg = 'In :get_range mode, :chunk_size must be provided'
58
+ msg = "Invalid mode #{@mode} provided, "\
59
+ 'mode should be :single_request, :get_range or :auto'
44
60
  raise ArgumentError, msg
45
61
  end
46
- else
47
- msg = "Invalid mode #{@mode} provided, "\
48
- 'mode should be :single_request, :get_range or :auto'
49
- raise ArgumentError, msg
50
62
  end
51
63
  end
52
64
 
53
65
  private
54
66
 
67
+ def validate!
68
+ if @on_checksum_validated && @params[:checksum_mode] != 'ENABLED'
69
+ raise ArgumentError, "You must set checksum_mode: 'ENABLED' " +
70
+ "when providing a on_checksum_validated callback"
71
+ end
72
+
73
+ if @on_checksum_validated && !@on_checksum_validated.respond_to?(:call)
74
+ raise ArgumentError, 'on_checksum_validated must be callable'
75
+ end
76
+ end
77
+
55
78
  def multipart_download
56
79
  resp = @client.head_object(@params.merge(part_number: 1))
57
80
  count = resp.parts_count
58
81
  if count.nil? || count <= 1
59
- resp.content_length < MIN_CHUNK_SIZE ?
60
- single_request :
82
+ if resp.content_length <= MIN_CHUNK_SIZE
83
+ single_request
84
+ else
61
85
  multithreaded_get_by_ranges(construct_chunks(resp.content_length))
86
+ end
62
87
  else
63
88
  # partNumber is an option
64
89
  resp = @client.head_object(@params)
65
- resp.content_length < MIN_CHUNK_SIZE ?
66
- single_request :
90
+ if resp.content_length <= MIN_CHUNK_SIZE
91
+ single_request
92
+ else
67
93
  compute_mode(resp.content_length, count)
94
+ end
68
95
  end
69
96
  end
70
97
 
@@ -82,10 +109,11 @@ module Aws
82
109
  offset = 0
83
110
  default_chunk_size = compute_chunk(file_size)
84
111
  chunks = []
85
- while offset <= file_size
112
+ while offset < file_size
86
113
  progress = offset + default_chunk_size
87
- chunks << "bytes=#{offset}-#{progress < file_size ? progress : file_size}"
88
- offset = progress + 1
114
+ progress = file_size if progress > file_size
115
+ chunks << "bytes=#{offset}-#{progress - 1}"
116
+ offset = progress
89
117
  end
90
118
  chunks
91
119
  end
@@ -94,12 +122,9 @@ module Aws
94
122
  if @chunk_size && @chunk_size > file_size
95
123
  raise ArgumentError, ":chunk_size shouldn't exceed total file size."
96
124
  else
97
- chunk_size = @chunk_size || [
98
- (file_size.to_f / MAX_PARTS).ceil,
99
- MIN_CHUNK_SIZE
125
+ @chunk_size || [
126
+ (file_size.to_f / MAX_PARTS).ceil, MIN_CHUNK_SIZE
100
127
  ].max.to_i
101
- chunk_size -= 1 if file_size % chunk_size == 1
102
- chunk_size
103
128
  end
104
129
  end
105
130
 
@@ -125,6 +150,9 @@ module Aws
125
150
  @params.merge(param.to_sym => chunk)
126
151
  )
127
152
  write(resp)
153
+ if @on_checksum_validated && resp.checksum_validated
154
+ @on_checksum_validated.call(resp.checksum_validated, resp)
155
+ end
128
156
  end
129
157
  end
130
158
  threads.each(&:join)
@@ -138,9 +166,17 @@ module Aws
138
166
  end
139
167
 
140
168
  def single_request
141
- @client.get_object(
169
+ resp = @client.get_object(
142
170
  @params.merge(response_target: @path)
143
171
  )
172
+
173
+ return resp unless @on_checksum_validated
174
+
175
+ if resp.checksum_validated
176
+ @on_checksum_validated.call(resp.checksum_validated, resp)
177
+ end
178
+
179
+ resp
144
180
  end
145
181
  end
146
182
  end
@@ -37,12 +37,14 @@ module Aws
37
37
  # objects smaller than the multipart threshold.
38
38
  # @return [void]
39
39
  def upload(source, options = {})
40
- if File.size(source) >= multipart_threshold
41
- MultipartFileUploader.new(@options).upload(source, options)
42
- else
43
- # remove multipart parameters not supported by put_object
44
- options.delete(:thread_count)
45
- put_object(source, options)
40
+ Aws::Plugins::UserAgent.feature('s3-transfer') do
41
+ if File.size(source) >= multipart_threshold
42
+ MultipartFileUploader.new(@options).upload(source, options)
43
+ else
44
+ # remove multipart parameters not supported by put_object
45
+ options.delete(:thread_count)
46
+ put_object(source, options)
47
+ end
46
48
  end
47
49
  end
48
50
 
@@ -45,9 +45,11 @@ module Aws
45
45
  # @option options [required,String] :key
46
46
  # @return [Seahorse::Client::Response] - the CompleteMultipartUploadResponse
47
47
  def upload(options = {}, &block)
48
- upload_id = initiate_upload(options)
49
- parts = upload_parts(upload_id, options, &block)
50
- complete_upload(upload_id, parts, options)
48
+ Aws::Plugins::UserAgent.feature('s3-transfer') do
49
+ upload_id = initiate_upload(options)
50
+ parts = upload_parts(upload_id, options, &block)
51
+ complete_upload(upload_id, parts, options)
52
+ end
51
53
  end
52
54
 
53
55
  private
@@ -217,7 +217,9 @@ module Aws::S3
217
217
  :retry
218
218
  end
219
219
  end
220
- Aws::Waiters::Waiter.new(options).wait({})
220
+ Aws::Plugins::UserAgent.feature('resource') do
221
+ Aws::Waiters::Waiter.new(options).wait({})
222
+ end
221
223
  end
222
224
 
223
225
  # @!group Actions
@@ -250,7 +252,9 @@ module Aws::S3
250
252
  key: @object_key,
251
253
  upload_id: @id
252
254
  )
253
- resp = @client.abort_multipart_upload(options)
255
+ resp = Aws::Plugins::UserAgent.feature('resource') do
256
+ @client.abort_multipart_upload(options)
257
+ end
254
258
  resp.data
255
259
  end
256
260
 
@@ -370,7 +374,9 @@ module Aws::S3
370
374
  key: @object_key,
371
375
  upload_id: @id
372
376
  )
373
- @client.complete_multipart_upload(options)
377
+ Aws::Plugins::UserAgent.feature('resource') do
378
+ @client.complete_multipart_upload(options)
379
+ end
374
380
  Object.new(
375
381
  bucket_name: @bucket_name,
376
382
  key: @object_key,
@@ -460,7 +466,9 @@ module Aws::S3
460
466
  key: @object_key,
461
467
  upload_id: @id
462
468
  )
463
- resp = @client.list_parts(options)
469
+ resp = Aws::Plugins::UserAgent.feature('resource') do
470
+ @client.list_parts(options)
471
+ end
464
472
  resp.each_page do |page|
465
473
  batch = []
466
474
  page.data.parts.each do |p|
@@ -256,7 +256,9 @@ module Aws::S3
256
256
  :retry
257
257
  end
258
258
  end
259
- Aws::Waiters::Waiter.new(options).wait({})
259
+ Aws::Plugins::UserAgent.feature('resource') do
260
+ Aws::Waiters::Waiter.new(options).wait({})
261
+ end
260
262
  end
261
263
 
262
264
  # @!group Actions
@@ -284,7 +286,7 @@ module Aws::S3
284
286
  # @option options [required, String] :copy_source
285
287
  # Specifies the source object for the copy operation. You specify the
286
288
  # value in one of two formats, depending on whether you want to access
287
- # the source object through an [access point][1]\:
289
+ # the source object through an [access point][1]:
288
290
  #
289
291
  # * For objects not accessed through an access point, specify the name
290
292
  # of the source bucket and key of the source object, separated by a
@@ -395,7 +397,9 @@ module Aws::S3
395
397
  upload_id: @multipart_upload_id,
396
398
  part_number: @part_number
397
399
  )
398
- resp = @client.upload_part_copy(options)
400
+ resp = Aws::Plugins::UserAgent.feature('resource') do
401
+ @client.upload_part_copy(options)
402
+ end
399
403
  resp.data
400
404
  end
401
405
 
@@ -521,7 +525,9 @@ module Aws::S3
521
525
  upload_id: @multipart_upload_id,
522
526
  part_number: @part_number
523
527
  )
524
- resp = @client.upload_part(options)
528
+ resp = Aws::Plugins::UserAgent.feature('resource') do
529
+ @client.upload_part(options)
530
+ end
525
531
  resp.data
526
532
  end
527
533