aws-sdk-s3 1.193.0 → 1.211.0

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +130 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-s3/bucket.rb +1 -1
  5. data/lib/aws-sdk-s3/bucket_acl.rb +1 -1
  6. data/lib/aws-sdk-s3/bucket_versioning.rb +33 -0
  7. data/lib/aws-sdk-s3/client.rb +918 -363
  8. data/lib/aws-sdk-s3/client_api.rb +63 -0
  9. data/lib/aws-sdk-s3/customizations/object.rb +76 -86
  10. data/lib/aws-sdk-s3/customizations.rb +4 -1
  11. data/lib/aws-sdk-s3/default_executor.rb +103 -0
  12. data/lib/aws-sdk-s3/encryption/client.rb +2 -2
  13. data/lib/aws-sdk-s3/encryption/default_cipher_provider.rb +2 -0
  14. data/lib/aws-sdk-s3/encryption/encrypt_handler.rb +2 -0
  15. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +2 -0
  16. data/lib/aws-sdk-s3/encryptionV2/client.rb +98 -23
  17. data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +7 -162
  18. data/lib/aws-sdk-s3/encryptionV2/decryption.rb +205 -0
  19. data/lib/aws-sdk-s3/encryptionV2/default_cipher_provider.rb +17 -0
  20. data/lib/aws-sdk-s3/encryptionV2/encrypt_handler.rb +2 -0
  21. data/lib/aws-sdk-s3/encryptionV2/io_encrypter.rb +2 -0
  22. data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +8 -0
  23. data/lib/aws-sdk-s3/encryptionV2/utils.rb +5 -0
  24. data/lib/aws-sdk-s3/encryptionV3/client.rb +885 -0
  25. data/lib/aws-sdk-s3/encryptionV3/decrypt_handler.rb +98 -0
  26. data/lib/aws-sdk-s3/encryptionV3/decryption.rb +244 -0
  27. data/lib/aws-sdk-s3/encryptionV3/default_cipher_provider.rb +159 -0
  28. data/lib/aws-sdk-s3/encryptionV3/default_key_provider.rb +35 -0
  29. data/lib/aws-sdk-s3/encryptionV3/encrypt_handler.rb +98 -0
  30. data/lib/aws-sdk-s3/encryptionV3/errors.rb +47 -0
  31. data/lib/aws-sdk-s3/encryptionV3/io_auth_decrypter.rb +60 -0
  32. data/lib/aws-sdk-s3/encryptionV3/io_decrypter.rb +35 -0
  33. data/lib/aws-sdk-s3/encryptionV3/io_encrypter.rb +84 -0
  34. data/lib/aws-sdk-s3/encryptionV3/key_provider.rb +28 -0
  35. data/lib/aws-sdk-s3/encryptionV3/kms_cipher_provider.rb +159 -0
  36. data/lib/aws-sdk-s3/encryptionV3/materials.rb +58 -0
  37. data/lib/aws-sdk-s3/encryptionV3/utils.rb +321 -0
  38. data/lib/aws-sdk-s3/encryption_v2.rb +1 -0
  39. data/lib/aws-sdk-s3/encryption_v3.rb +24 -0
  40. data/lib/aws-sdk-s3/endpoint_parameters.rb +17 -17
  41. data/lib/aws-sdk-s3/endpoint_provider.rb +241 -68
  42. data/lib/aws-sdk-s3/endpoints.rb +26 -0
  43. data/lib/aws-sdk-s3/file_downloader.rb +197 -134
  44. data/lib/aws-sdk-s3/file_uploader.rb +17 -13
  45. data/lib/aws-sdk-s3/multipart_download_error.rb +8 -0
  46. data/lib/aws-sdk-s3/multipart_file_uploader.rb +95 -107
  47. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +96 -107
  48. data/lib/aws-sdk-s3/multipart_upload_error.rb +3 -4
  49. data/lib/aws-sdk-s3/object.rb +56 -27
  50. data/lib/aws-sdk-s3/object_acl.rb +1 -1
  51. data/lib/aws-sdk-s3/object_summary.rb +42 -13
  52. data/lib/aws-sdk-s3/object_version.rb +7 -9
  53. data/lib/aws-sdk-s3/plugins/checksum_algorithm.rb +18 -5
  54. data/lib/aws-sdk-s3/plugins/endpoints.rb +1 -1
  55. data/lib/aws-sdk-s3/plugins/http_200_errors.rb +58 -34
  56. data/lib/aws-sdk-s3/transfer_manager.rb +321 -0
  57. data/lib/aws-sdk-s3/types.rb +380 -216
  58. data/lib/aws-sdk-s3.rb +1 -1
  59. data/sig/bucket.rbs +1 -1
  60. data/sig/client.rbs +41 -12
  61. data/sig/multipart_upload.rbs +1 -1
  62. data/sig/object.rbs +7 -5
  63. data/sig/object_summary.rbs +7 -5
  64. data/sig/resource.rbs +1 -0
  65. data/sig/types.rbs +47 -14
  66. metadata +22 -3
@@ -136,10 +136,10 @@ module Aws::S3
136
136
  end
137
137
 
138
138
  # The Base64 encoded, 32-bit `CRC32 checksum` of the object. This
139
- # checksum is only be present if the checksum was uploaded with the
140
- # object. When you use an API operation on an object that was uploaded
141
- # using multipart uploads, this value may not be a direct checksum value
142
- # of the full object. Instead, it's a calculation based on the checksum
139
+ # checksum is only present if the checksum was uploaded with the object.
140
+ # When you use an API operation on an object that was uploaded using
141
+ # multipart uploads, this value may not be a direct checksum value of
142
+ # the full object. Instead, it's a calculation based on the checksum
143
143
  # values of each individual part. For more information about how
144
144
  # checksums are calculated with multipart uploads, see [ Checking object
145
145
  # integrity][1] in the *Amazon S3 User Guide*.
@@ -181,8 +181,8 @@ module Aws::S3
181
181
  data[:checksum_crc64nvme]
182
182
  end
183
183
 
184
- # The Base64 encoded, 160-bit `SHA1` digest of the object. This will
185
- # only be present if the object was uploaded with the object. When you
184
+ # The Base64 encoded, 160-bit `SHA1` digest of the object. This checksum
185
+ # is only present if the checksum was uploaded with the object. When you
186
186
  # use the API operation on an object that was uploaded using multipart
187
187
  # uploads, this value may not be a direct checksum value of the full
188
188
  # object. Instead, it's a calculation based on the checksum values of
@@ -198,14 +198,14 @@ module Aws::S3
198
198
  data[:checksum_sha1]
199
199
  end
200
200
 
201
- # The Base64 encoded, 256-bit `SHA256` digest of the object. This will
202
- # only be present if the object was uploaded with the object. When you
203
- # use an API operation on an object that was uploaded using multipart
204
- # uploads, this value may not be a direct checksum value of the full
205
- # object. Instead, it's a calculation based on the checksum values of
206
- # each individual part. For more information about how checksums are
207
- # calculated with multipart uploads, see [ Checking object integrity][1]
208
- # in the *Amazon S3 User Guide*.
201
+ # The Base64 encoded, 256-bit `SHA256` digest of the object. This
202
+ # checksum is only present if the checksum was uploaded with the object.
203
+ # When you use an API operation on an object that was uploaded using
204
+ # multipart uploads, this value may not be a direct checksum value of
205
+ # the full object. Instead, it's a calculation based on the checksum
206
+ # values of each individual part. For more information about how
207
+ # checksums are calculated with multipart uploads, see [ Checking object
208
+ # integrity][1] in the *Amazon S3 User Guide*.
209
209
  #
210
210
  #
211
211
  #
@@ -757,13 +757,15 @@ module Aws::S3
757
757
  # grant_read: "GrantRead",
758
758
  # grant_read_acp: "GrantReadACP",
759
759
  # grant_write_acp: "GrantWriteACP",
760
+ # if_match: "IfMatch",
761
+ # if_none_match: "IfNoneMatch",
760
762
  # metadata: {
761
763
  # "MetadataKey" => "MetadataValue",
762
764
  # },
763
765
  # metadata_directive: "COPY", # accepts COPY, REPLACE
764
766
  # tagging_directive: "COPY", # accepts COPY, REPLACE
765
767
  # server_side_encryption: "AES256", # accepts AES256, aws:fsx, aws:kms, aws:kms:dsse
766
- # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS
768
+ # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS, FSX_ONTAP
767
769
  # website_redirect_location: "WebsiteRedirectLocation",
768
770
  # sse_customer_algorithm: "SSECustomerAlgorithm",
769
771
  # sse_customer_key: "SSECustomerKey",
@@ -1013,6 +1015,35 @@ module Aws::S3
1013
1015
  # * This functionality is not supported for Amazon S3 on Outposts.
1014
1016
  #
1015
1017
  # </note>
1018
+ # @option options [String] :if_match
1019
+ # Copies the object if the entity tag (ETag) of the destination object
1020
+ # matches the specified tag. If the ETag values do not match, the
1021
+ # operation returns a `412 Precondition Failed` error. If a concurrent
1022
+ # operation occurs during the upload S3 returns a `409
1023
+ # ConditionalRequestConflict` response. On a 409 failure you should
1024
+ # fetch the object's ETag and retry the upload.
1025
+ #
1026
+ # Expects the ETag value as a string.
1027
+ #
1028
+ # For more information about conditional requests, see [RFC 7232][1].
1029
+ #
1030
+ #
1031
+ #
1032
+ # [1]: https://tools.ietf.org/html/rfc7232
1033
+ # @option options [String] :if_none_match
1034
+ # Copies the object only if the object key name at the destination does
1035
+ # not already exist in the bucket specified. Otherwise, Amazon S3
1036
+ # returns a `412 Precondition Failed` error. If a concurrent operation
1037
+ # occurs during the upload S3 returns a `409 ConditionalRequestConflict`
1038
+ # response. On a 409 failure you should retry the upload.
1039
+ #
1040
+ # Expects the '*' (asterisk) character.
1041
+ #
1042
+ # For more information about conditional requests, see [RFC 7232][1].
1043
+ #
1044
+ #
1045
+ #
1046
+ # [1]: https://tools.ietf.org/html/rfc7232
1016
1047
  # @option options [Hash<String,String>] :metadata
1017
1048
  # A map of metadata to store with the object in S3.
1018
1049
  # @option options [String] :metadata_directive
@@ -1535,17 +1566,15 @@ module Aws::S3
1535
1566
  # you provide does not match the actual owner of the bucket, the request
1536
1567
  # fails with the HTTP status code `403 Forbidden` (access denied).
1537
1568
  # @option options [String] :if_match
1538
- # The `If-Match` header field makes the request method conditional on
1539
- # ETags. If the ETag value does not match, the operation returns a `412
1540
- # Precondition Failed` error. If the ETag matches or if the object
1541
- # doesn't exist, the operation will return a `204 Success (No Content)
1542
- # response`.
1543
- #
1544
- # For more information about conditional requests, see [RFC 7232][1].
1569
+ # Deletes the object if the ETag (entity tag) value provided during the
1570
+ # delete operation matches the ETag of the object in S3. If the ETag
1571
+ # values do not match, the operation returns a `412 Precondition Failed`
1572
+ # error.
1545
1573
  #
1546
- # <note markdown="1"> This functionality is only supported for directory buckets.
1574
+ # Expects the ETag value as a string. `If-Match` does accept a string
1575
+ # value of an '*' (asterisk) character to denote a match of any ETag.
1547
1576
  #
1548
- # </note>
1577
+ # For more information about conditional requests, see [RFC 7232][1].
1549
1578
  #
1550
1579
  #
1551
1580
  #
@@ -1860,7 +1889,7 @@ module Aws::S3
1860
1889
  # "MetadataKey" => "MetadataValue",
1861
1890
  # },
1862
1891
  # server_side_encryption: "AES256", # accepts AES256, aws:fsx, aws:kms, aws:kms:dsse
1863
- # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS
1892
+ # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS, FSX_ONTAP
1864
1893
  # website_redirect_location: "WebsiteRedirectLocation",
1865
1894
  # sse_customer_algorithm: "SSECustomerAlgorithm",
1866
1895
  # sse_customer_key: "SSECustomerKey",
@@ -2461,7 +2490,7 @@ module Aws::S3
2461
2490
  # "MetadataKey" => "MetadataValue",
2462
2491
  # },
2463
2492
  # server_side_encryption: "AES256", # accepts AES256, aws:fsx, aws:kms, aws:kms:dsse
2464
- # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS
2493
+ # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS, FSX_ONTAP
2465
2494
  # website_redirect_location: "WebsiteRedirectLocation",
2466
2495
  # sse_customer_algorithm: "SSECustomerAlgorithm",
2467
2496
  # sse_customer_key: "SSECustomerKey",
@@ -3136,7 +3165,7 @@ module Aws::S3
3136
3165
  # value: "MetadataValue",
3137
3166
  # },
3138
3167
  # ],
3139
- # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS
3168
+ # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS, FSX_ONTAP
3140
3169
  # },
3141
3170
  # },
3142
3171
  # },
@@ -42,7 +42,7 @@ module Aws::S3
42
42
  @object_key
43
43
  end
44
44
 
45
- # Container for the bucket owner's display name and ID.
45
+ # Container for the bucket owner's ID.
46
46
  # @return [Types::Owner]
47
47
  def owner
48
48
  data[:owner]
@@ -354,13 +354,15 @@ module Aws::S3
354
354
  # grant_read: "GrantRead",
355
355
  # grant_read_acp: "GrantReadACP",
356
356
  # grant_write_acp: "GrantWriteACP",
357
+ # if_match: "IfMatch",
358
+ # if_none_match: "IfNoneMatch",
357
359
  # metadata: {
358
360
  # "MetadataKey" => "MetadataValue",
359
361
  # },
360
362
  # metadata_directive: "COPY", # accepts COPY, REPLACE
361
363
  # tagging_directive: "COPY", # accepts COPY, REPLACE
362
364
  # server_side_encryption: "AES256", # accepts AES256, aws:fsx, aws:kms, aws:kms:dsse
363
- # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS
365
+ # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS, FSX_ONTAP
364
366
  # website_redirect_location: "WebsiteRedirectLocation",
365
367
  # sse_customer_algorithm: "SSECustomerAlgorithm",
366
368
  # sse_customer_key: "SSECustomerKey",
@@ -610,6 +612,35 @@ module Aws::S3
610
612
  # * This functionality is not supported for Amazon S3 on Outposts.
611
613
  #
612
614
  # </note>
615
+ # @option options [String] :if_match
616
+ # Copies the object if the entity tag (ETag) of the destination object
617
+ # matches the specified tag. If the ETag values do not match, the
618
+ # operation returns a `412 Precondition Failed` error. If a concurrent
619
+ # operation occurs during the upload S3 returns a `409
620
+ # ConditionalRequestConflict` response. On a 409 failure you should
621
+ # fetch the object's ETag and retry the upload.
622
+ #
623
+ # Expects the ETag value as a string.
624
+ #
625
+ # For more information about conditional requests, see [RFC 7232][1].
626
+ #
627
+ #
628
+ #
629
+ # [1]: https://tools.ietf.org/html/rfc7232
630
+ # @option options [String] :if_none_match
631
+ # Copies the object only if the object key name at the destination does
632
+ # not already exist in the bucket specified. Otherwise, Amazon S3
633
+ # returns a `412 Precondition Failed` error. If a concurrent operation
634
+ # occurs during the upload S3 returns a `409 ConditionalRequestConflict`
635
+ # response. On a 409 failure you should retry the upload.
636
+ #
637
+ # Expects the '*' (asterisk) character.
638
+ #
639
+ # For more information about conditional requests, see [RFC 7232][1].
640
+ #
641
+ #
642
+ #
643
+ # [1]: https://tools.ietf.org/html/rfc7232
613
644
  # @option options [Hash<String,String>] :metadata
614
645
  # A map of metadata to store with the object in S3.
615
646
  # @option options [String] :metadata_directive
@@ -1132,17 +1163,15 @@ module Aws::S3
1132
1163
  # you provide does not match the actual owner of the bucket, the request
1133
1164
  # fails with the HTTP status code `403 Forbidden` (access denied).
1134
1165
  # @option options [String] :if_match
1135
- # The `If-Match` header field makes the request method conditional on
1136
- # ETags. If the ETag value does not match, the operation returns a `412
1137
- # Precondition Failed` error. If the ETag matches or if the object
1138
- # doesn't exist, the operation will return a `204 Success (No Content)
1139
- # response`.
1166
+ # Deletes the object if the ETag (entity tag) value provided during the
1167
+ # delete operation matches the ETag of the object in S3. If the ETag
1168
+ # values do not match, the operation returns a `412 Precondition Failed`
1169
+ # error.
1140
1170
  #
1141
- # For more information about conditional requests, see [RFC 7232][1].
1171
+ # Expects the ETag value as a string. `If-Match` does accept a string
1172
+ # value of an '*' (asterisk) character to denote a match of any ETag.
1142
1173
  #
1143
- # <note markdown="1"> This functionality is only supported for directory buckets.
1144
- #
1145
- # </note>
1174
+ # For more information about conditional requests, see [RFC 7232][1].
1146
1175
  #
1147
1176
  #
1148
1177
  #
@@ -1457,7 +1486,7 @@ module Aws::S3
1457
1486
  # "MetadataKey" => "MetadataValue",
1458
1487
  # },
1459
1488
  # server_side_encryption: "AES256", # accepts AES256, aws:fsx, aws:kms, aws:kms:dsse
1460
- # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS
1489
+ # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS, FSX_ONTAP
1461
1490
  # website_redirect_location: "WebsiteRedirectLocation",
1462
1491
  # sse_customer_algorithm: "SSECustomerAlgorithm",
1463
1492
  # sse_customer_key: "SSECustomerKey",
@@ -2058,7 +2087,7 @@ module Aws::S3
2058
2087
  # "MetadataKey" => "MetadataValue",
2059
2088
  # },
2060
2089
  # server_side_encryption: "AES256", # accepts AES256, aws:fsx, aws:kms, aws:kms:dsse
2061
- # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS
2090
+ # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS, FSX_ONTAP
2062
2091
  # website_redirect_location: "WebsiteRedirectLocation",
2063
2092
  # sse_customer_algorithm: "SSECustomerAlgorithm",
2064
2093
  # sse_customer_key: "SSECustomerKey",
@@ -2733,7 +2762,7 @@ module Aws::S3
2733
2762
  # value: "MetadataValue",
2734
2763
  # },
2735
2764
  # ],
2736
- # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS
2765
+ # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS, FSX_ONTAP
2737
2766
  # },
2738
2767
  # },
2739
2768
  # },
@@ -312,17 +312,15 @@ module Aws::S3
312
312
  # you provide does not match the actual owner of the bucket, the request
313
313
  # fails with the HTTP status code `403 Forbidden` (access denied).
314
314
  # @option options [String] :if_match
315
- # The `If-Match` header field makes the request method conditional on
316
- # ETags. If the ETag value does not match, the operation returns a `412
317
- # Precondition Failed` error. If the ETag matches or if the object
318
- # doesn't exist, the operation will return a `204 Success (No Content)
319
- # response`.
320
- #
321
- # For more information about conditional requests, see [RFC 7232][1].
315
+ # Deletes the object if the ETag (entity tag) value provided during the
316
+ # delete operation matches the ETag of the object in S3. If the ETag
317
+ # values do not match, the operation returns a `412 Precondition Failed`
318
+ # error.
322
319
  #
323
- # <note markdown="1"> This functionality is only supported for directory buckets.
320
+ # Expects the ETag value as a string. `If-Match` does accept a string
321
+ # value of an '*' (asterisk) character to denote a match of any ETag.
324
322
  #
325
- # </note>
323
+ # For more information about conditional requests, see [RFC 7232][1].
326
324
  #
327
325
  #
328
326
  #
@@ -18,12 +18,25 @@ module Aws
18
18
  end
19
19
  end
20
20
 
21
+ # Handler to disable trailer checksums for S3-compatible services
22
+ # that don't support STREAMING-UNSIGNED-PAYLOAD-TRAILER
23
+ # See: https://github.com/aws/aws-sdk-ruby/issues/3338
24
+ class SkipTrailerChecksumsHandler < Seahorse::Client::Handler
25
+ def call(context)
26
+ context[:skip_trailer_checksums] = true if custom_endpoint?(context.config)
27
+ @handler.call(context)
28
+ end
29
+
30
+ private
31
+
32
+ def custom_endpoint?(config)
33
+ !config.regional_endpoint || !config.endpoint_provider.instance_of?(Aws::S3::EndpointProvider)
34
+ end
35
+ end
36
+
21
37
  def add_handlers(handlers, _config)
22
- handlers.add(
23
- SkipWholeMultipartGetChecksumsHandler,
24
- step: :initialize,
25
- operations: [:get_object]
26
- )
38
+ handlers.add(SkipWholeMultipartGetChecksumsHandler, step: :initialize, operations: [:get_object])
39
+ handlers.add(SkipTrailerChecksumsHandler, step: :build, priority: 16, operations: %i[put_object upload_part])
27
40
  end
28
41
  end
29
42
  end
@@ -25,7 +25,7 @@ The endpoint provider used to resolve endpoints. Any object that responds to
25
25
 
26
26
  option(
27
27
  :disable_s3_express_session_auth,
28
- doc_type: 'Boolean',
28
+ doc_type: 'boolean',
29
29
  docstring: <<~DOCS) do |cfg|
30
30
  Parameter to indicate whether S3Express session auth should be disabled
31
31
  DOCS
@@ -3,15 +3,28 @@
3
3
  module Aws
4
4
  module S3
5
5
  module Plugins
6
-
7
6
  # A handful of Amazon S3 operations will respond with a 200 status
8
7
  # code but will send an error in the response body. This plugin
9
8
  # injects a handler that will parse 200 response bodies for potential
10
9
  # errors, allowing them to be retried.
11
10
  # @api private
12
11
  class Http200Errors < Seahorse::Client::Plugin
13
-
14
12
  class Handler < Seahorse::Client::Handler
13
+ # A regular expression to match error codes in the response body
14
+ CODE_PATTERN = %r{<Code>(.+?)</Code>}.freeze
15
+ private_constant :CODE_PATTERN
16
+
17
+ # A list of encodings we force into UTF-8
18
+ ENCODINGS_TO_FIX = [Encoding::US_ASCII, Encoding::ASCII_8BIT].freeze
19
+ private_constant :ENCODINGS_TO_FIX
20
+
21
+ # A regular expression to match detect errors in the response body
22
+ ERROR_PATTERN = /<\?xml\s[^>]*\?>\s*<Error>/.freeze
23
+ private_constant :ERROR_PATTERN
24
+
25
+ # A regular expression to match an error message in the response body
26
+ MESSAGE_PATTERN = %r{<Message>(.+?)</Message>}.freeze
27
+ private_constant :MESSAGE_PATTERN
15
28
 
16
29
  def call(context)
17
30
  @handler.call(context).on(200) do |response|
@@ -28,29 +41,37 @@ module Aws
28
41
 
29
42
  private
30
43
 
31
- # Streaming outputs are not subject to 200 errors.
32
- def streaming_output?(output)
33
- if (payload = output[:payload_member])
34
- # checking ref and shape
35
- payload['streaming'] || payload.shape['streaming'] ||
36
- payload.eventstream
37
- else
38
- false
44
+ def build_error(context, code, message)
45
+ S3::Errors.error_class(code).new(context, message)
46
+ end
47
+
48
+ def check_for_error(context)
49
+ xml = normalize_encoding(context.http_response.body_contents)
50
+
51
+ if xml.match?(ERROR_PATTERN)
52
+ error_code = xml.match(CODE_PATTERN)[1]
53
+ error_message = xml.match(MESSAGE_PATTERN)[1]
54
+ build_error(context, error_code, error_message)
55
+ elsif incomplete_xml_body?(xml, context.operation.output)
56
+ Seahorse::Client::NetworkingError.new(
57
+ build_error(context, 'InternalError', 'Empty or incomplete response body')
58
+ )
39
59
  end
40
60
  end
41
61
 
62
+ # Must have a member in the body and have the start of an XML Tag.
63
+ # Other incomplete xml bodies will result in an XML ParsingError.
64
+ def incomplete_xml_body?(xml, output)
65
+ members_in_body?(output) && !xml.match(/<\w/)
66
+ end
67
+
42
68
  # Checks if the output shape is a structure shape and has members that
43
69
  # are in the body for the case of a payload and a normal structure. A
44
70
  # non-structure shape will not have members in the body. In the case
45
71
  # of a string or blob, the body contents would have been checked first
46
72
  # before this method is called in incomplete_xml_body?.
47
73
  def members_in_body?(output)
48
- shape =
49
- if output[:payload_member]
50
- output[:payload_member].shape
51
- else
52
- output.shape
53
- end
74
+ shape = resolve_shape(output)
54
75
 
55
76
  if structure_shape?(shape)
56
77
  shape.members.any? { |_, k| k.location.nil? }
@@ -59,30 +80,33 @@ module Aws
59
80
  end
60
81
  end
61
82
 
62
- def structure_shape?(shape)
63
- shape.is_a?(Seahorse::Model::Shapes::StructureShape)
83
+ # Fixes encoding issues when S3 returns UTF-8 content with missing charset in Content-Type header or omits
84
+ # Content-Type header entirely. Net::HTTP defaults to US-ASCII or ASCII-8BIT when charset is unspecified.
85
+ def normalize_encoding(xml)
86
+ return xml unless xml.is_a?(String) && ENCODINGS_TO_FIX.include?(xml.encoding)
87
+
88
+ xml.force_encoding('UTF-8')
64
89
  end
65
90
 
66
- # Must have a member in the body and have the start of an XML Tag.
67
- # Other incomplete xml bodies will result in an XML ParsingError.
68
- def incomplete_xml_body?(xml, output)
69
- members_in_body?(output) && !xml.match(/<\w/)
91
+ def resolve_shape(output)
92
+ return output.shape unless output[:payload_member]
93
+
94
+ output[:payload_member].shape
70
95
  end
71
96
 
72
- def check_for_error(context)
73
- xml = context.http_response.body_contents
74
- if xml.match(/<\?xml\s[^>]*\?>\s*<Error>/)
75
- error_code = xml.match(%r{<Code>(.+?)</Code>})[1]
76
- error_message = xml.match(%r{<Message>(.+?)</Message>})[1]
77
- S3::Errors.error_class(error_code).new(context, error_message)
78
- elsif incomplete_xml_body?(xml, context.operation.output)
79
- Seahorse::Client::NetworkingError.new(
80
- S3::Errors
81
- .error_class('InternalError')
82
- .new(context, 'Empty or incomplete response body')
83
- )
97
+ # Streaming outputs are not subject to 200 errors.
98
+ def streaming_output?(output)
99
+ if (payload = output[:payload_member])
100
+ # checking ref and shape
101
+ payload['streaming'] || payload.shape['streaming'] || payload.eventstream
102
+ else
103
+ false
84
104
  end
85
105
  end
106
+
107
+ def structure_shape?(shape)
108
+ shape.is_a?(Seahorse::Model::Shapes::StructureShape)
109
+ end
86
110
  end
87
111
 
88
112
  handler(Handler, step: :sign)