aws-sdk-s3 1.87.0 → 1.143.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1106 -0
  3. data/LICENSE.txt +202 -0
  4. data/VERSION +1 -0
  5. data/lib/aws-sdk-s3/bucket.rb +605 -114
  6. data/lib/aws-sdk-s3/bucket_acl.rb +36 -11
  7. data/lib/aws-sdk-s3/bucket_cors.rb +40 -15
  8. data/lib/aws-sdk-s3/bucket_lifecycle.rb +42 -15
  9. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +43 -13
  10. data/lib/aws-sdk-s3/bucket_logging.rb +40 -11
  11. data/lib/aws-sdk-s3/bucket_notification.rb +30 -12
  12. data/lib/aws-sdk-s3/bucket_policy.rb +82 -13
  13. data/lib/aws-sdk-s3/bucket_request_payment.rb +35 -13
  14. data/lib/aws-sdk-s3/bucket_tagging.rb +38 -13
  15. data/lib/aws-sdk-s3/bucket_versioning.rb +82 -21
  16. data/lib/aws-sdk-s3/bucket_website.rb +38 -13
  17. data/lib/aws-sdk-s3/client.rb +8666 -3425
  18. data/lib/aws-sdk-s3/client_api.rb +774 -225
  19. data/lib/aws-sdk-s3/customizations/bucket.rb +31 -50
  20. data/lib/aws-sdk-s3/customizations/errors.rb +27 -0
  21. data/lib/aws-sdk-s3/customizations/object.rb +211 -37
  22. data/lib/aws-sdk-s3/customizations/types/permanent_redirect.rb +26 -0
  23. data/lib/aws-sdk-s3/customizations.rb +7 -0
  24. data/lib/aws-sdk-s3/encryption/client.rb +7 -3
  25. data/lib/aws-sdk-s3/encryption/decrypt_handler.rb +0 -4
  26. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +13 -9
  27. data/lib/aws-sdk-s3/encryptionV2/client.rb +7 -3
  28. data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +1 -4
  29. data/lib/aws-sdk-s3/encryptionV2/default_cipher_provider.rb +3 -3
  30. data/lib/aws-sdk-s3/encryptionV2/encrypt_handler.rb +0 -4
  31. data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +10 -6
  32. data/lib/aws-sdk-s3/endpoint_parameters.rb +178 -0
  33. data/lib/aws-sdk-s3/endpoint_provider.rb +591 -0
  34. data/lib/aws-sdk-s3/endpoints.rb +2590 -0
  35. data/lib/aws-sdk-s3/errors.rb +1 -1
  36. data/lib/aws-sdk-s3/event_streams.rb +1 -1
  37. data/lib/aws-sdk-s3/express_credentials.rb +55 -0
  38. data/lib/aws-sdk-s3/express_credentials_cache.rb +30 -0
  39. data/lib/aws-sdk-s3/express_credentials_provider.rb +36 -0
  40. data/lib/aws-sdk-s3/file_downloader.rb +171 -41
  41. data/lib/aws-sdk-s3/file_uploader.rb +14 -7
  42. data/lib/aws-sdk-s3/multipart_file_uploader.rb +26 -8
  43. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +41 -14
  44. data/lib/aws-sdk-s3/multipart_upload.rb +198 -23
  45. data/lib/aws-sdk-s3/multipart_upload_part.rb +285 -34
  46. data/lib/aws-sdk-s3/object.rb +1824 -266
  47. data/lib/aws-sdk-s3/object_acl.rb +58 -19
  48. data/lib/aws-sdk-s3/object_copier.rb +7 -5
  49. data/lib/aws-sdk-s3/object_multipart_copier.rb +41 -19
  50. data/lib/aws-sdk-s3/object_summary.rb +1579 -299
  51. data/lib/aws-sdk-s3/object_version.rb +372 -64
  52. data/lib/aws-sdk-s3/plugins/accelerate.rb +1 -39
  53. data/lib/aws-sdk-s3/plugins/arn.rb +25 -142
  54. data/lib/aws-sdk-s3/plugins/bucket_dns.rb +3 -39
  55. data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +1 -6
  56. data/lib/aws-sdk-s3/plugins/dualstack.rb +2 -49
  57. data/lib/aws-sdk-s3/plugins/endpoints.rb +274 -0
  58. data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +3 -1
  59. data/lib/aws-sdk-s3/plugins/express_session_auth.rb +91 -0
  60. data/lib/aws-sdk-s3/plugins/get_bucket_location_fix.rb +1 -1
  61. data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +8 -31
  62. data/lib/aws-sdk-s3/plugins/location_constraint.rb +3 -1
  63. data/lib/aws-sdk-s3/plugins/md5s.rb +6 -3
  64. data/lib/aws-sdk-s3/plugins/s3_signer.rb +35 -102
  65. data/lib/aws-sdk-s3/plugins/skip_whole_multipart_get_checksums.rb +31 -0
  66. data/lib/aws-sdk-s3/plugins/streaming_retry.rb +23 -2
  67. data/lib/aws-sdk-s3/presigned_post.rb +99 -78
  68. data/lib/aws-sdk-s3/presigner.rb +43 -51
  69. data/lib/aws-sdk-s3/resource.rb +102 -6
  70. data/lib/aws-sdk-s3/types.rb +7404 -5114
  71. data/lib/aws-sdk-s3/waiters.rb +1 -1
  72. data/lib/aws-sdk-s3.rb +6 -2
  73. data/sig/bucket.rbs +212 -0
  74. data/sig/bucket_acl.rbs +78 -0
  75. data/sig/bucket_cors.rbs +69 -0
  76. data/sig/bucket_lifecycle.rbs +88 -0
  77. data/sig/bucket_lifecycle_configuration.rbs +111 -0
  78. data/sig/bucket_logging.rbs +76 -0
  79. data/sig/bucket_notification.rbs +114 -0
  80. data/sig/bucket_policy.rbs +59 -0
  81. data/sig/bucket_request_payment.rbs +54 -0
  82. data/sig/bucket_tagging.rbs +65 -0
  83. data/sig/bucket_versioning.rbs +77 -0
  84. data/sig/bucket_website.rbs +93 -0
  85. data/sig/client.rbs +2360 -0
  86. data/sig/errors.rbs +34 -0
  87. data/sig/multipart_upload.rbs +110 -0
  88. data/sig/multipart_upload_part.rbs +105 -0
  89. data/sig/object.rbs +436 -0
  90. data/sig/object_acl.rbs +86 -0
  91. data/sig/object_summary.rbs +334 -0
  92. data/sig/object_version.rbs +131 -0
  93. data/sig/resource.rbs +124 -0
  94. data/sig/types.rbs +2562 -0
  95. data/sig/waiters.rbs +83 -0
  96. metadata +51 -17
  97. data/lib/aws-sdk-s3/arn/access_point_arn.rb +0 -62
  98. data/lib/aws-sdk-s3/arn/outpost_access_point_arn.rb +0 -71
@@ -3,7 +3,7 @@
3
3
  # WARNING ABOUT GENERATED CODE
4
4
  #
5
5
  # This file is generated. See the contributing guide for more information:
6
- # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
7
  #
8
8
  # WARNING ABOUT GENERATED CODE
9
9
 
@@ -56,6 +56,10 @@ module Aws::S3
56
56
 
57
57
  # If present, indicates that the requester was successfully charged for
58
58
  # the request.
59
+ #
60
+ # <note markdown="1"> This functionality is not supported for directory buckets.
61
+ #
62
+ # </note>
59
63
  # @return [String]
60
64
  def request_charged
61
65
  data[:request_charged]
@@ -75,10 +79,12 @@ module Aws::S3
75
79
  #
76
80
  # @return [self]
77
81
  def load
78
- resp = @client.get_object_acl(
82
+ resp = Aws::Plugins::UserAgent.feature('resource') do
83
+ @client.get_object_acl(
79
84
  bucket: @bucket_name,
80
85
  key: @object_key
81
86
  )
87
+ end
82
88
  @data = resp.data
83
89
  self
84
90
  end
@@ -193,7 +199,9 @@ module Aws::S3
193
199
  :retry
194
200
  end
195
201
  end
196
- Aws::Waiters::Waiter.new(options).wait({})
202
+ Aws::Plugins::UserAgent.feature('resource') do
203
+ Aws::Waiters::Waiter.new(options).wait({})
204
+ end
197
205
  end
198
206
 
199
207
  # @!group Actions
@@ -221,6 +229,7 @@ module Aws::S3
221
229
  # },
222
230
  # },
223
231
  # content_md5: "ContentMD5",
232
+ # checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256
224
233
  # grant_full_control: "GrantFullControl",
225
234
  # grant_read: "GrantRead",
226
235
  # grant_read_acp: "GrantReadACP",
@@ -247,55 +256,85 @@ module Aws::S3
247
256
  # not corrupted in transit. For more information, go to [RFC
248
257
  # 1864.&gt;][1]
249
258
  #
250
- # For requests made using the AWS Command Line Interface (CLI) or AWS
251
- # SDKs, this field is calculated automatically.
259
+ # For requests made using the Amazon Web Services Command Line Interface
260
+ # (CLI) or Amazon Web Services SDKs, this field is calculated
261
+ # automatically.
252
262
  #
253
263
  #
254
264
  #
255
265
  # [1]: http://www.ietf.org/rfc/rfc1864.txt
266
+ # @option options [String] :checksum_algorithm
267
+ # Indicates the algorithm used to create the checksum for the object
268
+ # when you use the SDK. This header will not provide any additional
269
+ # functionality if you don't use the SDK. When you send this header,
270
+ # there must be a corresponding `x-amz-checksum` or `x-amz-trailer`
271
+ # header sent. Otherwise, Amazon S3 fails the request with the HTTP
272
+ # status code `400 Bad Request`. For more information, see [Checking
273
+ # object integrity][1] in the *Amazon S3 User Guide*.
274
+ #
275
+ # If you provide an individual checksum, Amazon S3 ignores any provided
276
+ # `ChecksumAlgorithm` parameter.
277
+ #
278
+ #
279
+ #
280
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html
256
281
  # @option options [String] :grant_full_control
257
282
  # Allows grantee the read, write, read ACP, and write ACP permissions on
258
283
  # the bucket.
259
284
  #
260
- # This action is not supported by Amazon S3 on Outposts.
285
+ # This functionality is not supported for Amazon S3 on Outposts.
261
286
  # @option options [String] :grant_read
262
287
  # Allows grantee to list the objects in the bucket.
263
288
  #
264
- # This action is not supported by Amazon S3 on Outposts.
289
+ # This functionality is not supported for Amazon S3 on Outposts.
265
290
  # @option options [String] :grant_read_acp
266
291
  # Allows grantee to read the bucket ACL.
267
292
  #
268
- # This action is not supported by Amazon S3 on Outposts.
293
+ # This functionality is not supported for Amazon S3 on Outposts.
269
294
  # @option options [String] :grant_write
270
- # Allows grantee to create, overwrite, and delete any object in the
271
- # bucket.
295
+ # Allows grantee to create new objects in the bucket.
296
+ #
297
+ # For the bucket and object owners of existing objects, also allows
298
+ # deletions and overwrites of those objects.
272
299
  # @option options [String] :grant_write_acp
273
300
  # Allows grantee to write the ACL for the applicable bucket.
274
301
  #
275
- # This action is not supported by Amazon S3 on Outposts.
302
+ # This functionality is not supported for Amazon S3 on Outposts.
276
303
  # @option options [String] :request_payer
277
304
  # Confirms that the requester knows that they will be charged for the
278
305
  # request. Bucket owners need not specify this parameter in their
279
- # requests. For information about downloading objects from requester
280
- # pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
281
- # in the *Amazon S3 Developer Guide*.
306
+ # requests. If either the source or destination S3 bucket has Requester
307
+ # Pays enabled, the requester will pay for corresponding charges to copy
308
+ # the object. For information about downloading objects from Requester
309
+ # Pays buckets, see [Downloading Objects in Requester Pays Buckets][1]
310
+ # in the *Amazon S3 User Guide*.
311
+ #
312
+ # <note markdown="1"> This functionality is not supported for directory buckets.
313
+ #
314
+ # </note>
282
315
  #
283
316
  #
284
317
  #
285
318
  # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
286
319
  # @option options [String] :version_id
287
- # VersionId used to reference a specific version of the object.
320
+ # Version ID used to reference a specific version of the object.
321
+ #
322
+ # <note markdown="1"> This functionality is not supported for directory buckets.
323
+ #
324
+ # </note>
288
325
  # @option options [String] :expected_bucket_owner
289
- # The account id of the expected bucket owner. If the bucket is owned by
290
- # a different account, the request will fail with an HTTP `403 (Access
291
- # Denied)` error.
326
+ # The account ID of the expected bucket owner. If the account ID that
327
+ # you provide does not match the actual owner of the bucket, the request
328
+ # fails with the HTTP status code `403 Forbidden` (access denied).
292
329
  # @return [Types::PutObjectAclOutput]
293
330
  def put(options = {})
294
331
  options = options.merge(
295
332
  bucket: @bucket_name,
296
333
  key: @object_key
297
334
  )
298
- resp = @client.put_object_acl(options)
335
+ resp = Aws::Plugins::UserAgent.feature('resource') do
336
+ @client.put_object_acl(options)
337
+ end
299
338
  resp.data
300
339
  end
301
340
 
@@ -28,11 +28,13 @@ module Aws
28
28
  options[:bucket] = target_bucket
29
29
  options[:key] = target_key
30
30
  options[:copy_source] = copy_source(source)
31
- if options.delete(:multipart_copy)
32
- apply_source_client(source, options)
33
- ObjectMultipartCopier.new(@options).copy(options)
34
- else
35
- @object.client.copy_object(options)
31
+ Aws::Plugins::UserAgent.feature('s3-transfer') do
32
+ if options.delete(:multipart_copy)
33
+ apply_source_client(source, options)
34
+ ObjectMultipartCopier.new(@options).copy(options)
35
+ else
36
+ @object.client.copy_object(options)
37
+ end
36
38
  end
37
39
  end
38
40
 
@@ -15,12 +15,18 @@ module Aws
15
15
  MAX_PARTS = 10_000
16
16
 
17
17
  # @option options [Client] :client
18
- # @option [Integer] :min_part_size (52428800) Size of copied parts.
19
- # Defaults to 50MB.
20
- # will be constructed from the given `options' hash.
21
- # @option [Integer] :thread_count (10) Number of concurrent threads to
22
- # use for copying parts.
18
+ # @option options [Integer] :min_part_size (52428800)
19
+ # Size of copied parts. Defaults to 50MB.
20
+ # @option options [Integer] :thread_count (10) Number of concurrent
21
+ # threads to use for copying parts.
22
+ # @option options [Boolean] :use_source_parts (false) Use part sizes
23
+ # defined on the source object if any exist. If copying or moving an
24
+ # object that is already multipart, this does not re-part the object,
25
+ # instead re-using the part definitions on the original. That means
26
+ # the etag and any checksums will not change. This is especially
27
+ # useful if the source object has parts with varied sizes.
23
28
  def initialize(options = {})
29
+ @use_source_parts = options.delete(:use_source_parts) || false
24
30
  @thread_count = options.delete(:thread_count) || 10
25
31
  @min_part_size = options.delete(:min_part_size) || (FIVE_MB * 10)
26
32
  @client = options[:client] || Client.new
@@ -31,8 +37,9 @@ module Aws
31
37
 
32
38
  # @option (see S3::Client#copy_object)
33
39
  def copy(options = {})
34
- size = source_size(options)
35
- options[:upload_id] = initiate_upload(options)
40
+ metadata = source_metadata(options)
41
+ size = metadata[:content_length]
42
+ options[:upload_id] = initiate_upload(metadata.merge(options))
36
43
  begin
37
44
  parts = copy_parts(size, default_part_size(size), options)
38
45
  complete_upload(parts, options)
@@ -74,10 +81,9 @@ module Aws
74
81
  end
75
82
 
76
83
  def copy_part(part)
77
- {
78
- etag: @client.upload_part_copy(part).copy_part_result.etag,
79
- part_number: part[:part_number],
80
- }
84
+ @client.upload_part_copy(part).copy_part_result.to_h.merge({
85
+ part_number: part[:part_number]
86
+ }).tap { |result| result.delete(:last_modified) }
81
87
  end
82
88
 
83
89
  def complete_upload(parts, options)
@@ -100,26 +106,41 @@ module Aws
100
106
  parts = []
101
107
  options = options_for(:upload_part_copy, options)
102
108
  while offset < size
109
+ part_size = calculate_part_size(part_number, default_part_size, options)
103
110
  parts << options.merge({
104
111
  part_number: part_number,
105
- copy_source_range: byte_range(offset, default_part_size, size),
112
+ copy_source_range: byte_range(offset, part_size, size),
106
113
  })
107
114
  part_number += 1
108
- offset += default_part_size
115
+ offset += part_size
109
116
  end
110
117
  parts
111
118
  end
112
119
 
113
- def byte_range(offset, default_part_size, size)
114
- if offset + default_part_size < size
115
- "bytes=#{offset}-#{offset + default_part_size - 1}"
120
+ def byte_range(offset, part_size, size)
121
+ if offset + part_size < size
122
+ "bytes=#{offset}-#{offset + part_size - 1}"
116
123
  else
117
124
  "bytes=#{offset}-#{size - 1}"
118
125
  end
119
126
  end
120
127
 
121
- def source_size(options)
122
- return options.delete(:content_length) if options[:content_length]
128
+ def calculate_part_size(part_number, default_part_size, options)
129
+ if @use_source_parts && source_has_parts(options)
130
+ source_metadata(options.merge({ part_number: part_number }))[:content_length]
131
+ else
132
+ default_part_size
133
+ end
134
+ end
135
+
136
+ def source_has_parts(options)
137
+ @source_has_parts ||= source_metadata(options.merge({ part_number: 1 }))[:parts_count]
138
+ end
139
+
140
+ def source_metadata(options)
141
+ if options[:content_length]
142
+ return { content_length: options.delete(:content_length) }
143
+ end
123
144
 
124
145
  client = options[:copy_source_client] || @client
125
146
 
@@ -132,7 +153,8 @@ module Aws
132
153
  key = CGI.unescape(key)
133
154
  opts = { bucket: bucket, key: key }
134
155
  opts[:version_id] = version_id if version_id
135
- client.head_object(opts).content_length
156
+ opts[:part_number] = options[:part_number] if options[:part_number]
157
+ client.head_object(opts).to_h
136
158
  end
137
159
 
138
160
  def default_part_size(source_size)