aws-sdk-s3 1.142.0 → 1.208.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 (118) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +417 -1
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-s3/access_grants_credentials.rb +57 -0
  5. data/lib/aws-sdk-s3/access_grants_credentials_provider.rb +250 -0
  6. data/lib/aws-sdk-s3/bucket.rb +358 -106
  7. data/lib/aws-sdk-s3/bucket_acl.rb +10 -9
  8. data/lib/aws-sdk-s3/bucket_cors.rb +10 -9
  9. data/lib/aws-sdk-s3/bucket_lifecycle.rb +11 -6
  10. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +64 -7
  11. data/lib/aws-sdk-s3/bucket_logging.rb +5 -5
  12. data/lib/aws-sdk-s3/bucket_notification.rb +3 -3
  13. data/lib/aws-sdk-s3/bucket_policy.rb +14 -13
  14. data/lib/aws-sdk-s3/bucket_region_cache.rb +9 -5
  15. data/lib/aws-sdk-s3/bucket_request_payment.rb +6 -6
  16. data/lib/aws-sdk-s3/bucket_tagging.rb +7 -7
  17. data/lib/aws-sdk-s3/bucket_versioning.rb +47 -14
  18. data/lib/aws-sdk-s3/bucket_website.rb +7 -7
  19. data/lib/aws-sdk-s3/client.rb +5671 -2195
  20. data/lib/aws-sdk-s3/client_api.rb +665 -166
  21. data/lib/aws-sdk-s3/customizations/bucket.rb +1 -1
  22. data/lib/aws-sdk-s3/customizations/errors.rb +15 -2
  23. data/lib/aws-sdk-s3/customizations/object.rb +87 -91
  24. data/lib/aws-sdk-s3/customizations/object_summary.rb +5 -0
  25. data/lib/aws-sdk-s3/customizations/object_version.rb +13 -0
  26. data/lib/aws-sdk-s3/customizations.rb +28 -36
  27. data/lib/aws-sdk-s3/default_executor.rb +103 -0
  28. data/lib/aws-sdk-s3/encryption/client.rb +4 -4
  29. data/lib/aws-sdk-s3/encryption/default_cipher_provider.rb +2 -0
  30. data/lib/aws-sdk-s3/encryption/encrypt_handler.rb +2 -0
  31. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +4 -2
  32. data/lib/aws-sdk-s3/encryptionV2/client.rb +100 -25
  33. data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +7 -162
  34. data/lib/aws-sdk-s3/encryptionV2/decryption.rb +205 -0
  35. data/lib/aws-sdk-s3/encryptionV2/default_cipher_provider.rb +17 -0
  36. data/lib/aws-sdk-s3/encryptionV2/encrypt_handler.rb +2 -0
  37. data/lib/aws-sdk-s3/encryptionV2/io_encrypter.rb +2 -0
  38. data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +10 -2
  39. data/lib/aws-sdk-s3/encryptionV2/utils.rb +5 -0
  40. data/lib/aws-sdk-s3/encryptionV3/client.rb +885 -0
  41. data/lib/aws-sdk-s3/encryptionV3/decrypt_handler.rb +98 -0
  42. data/lib/aws-sdk-s3/encryptionV3/decryption.rb +244 -0
  43. data/lib/aws-sdk-s3/encryptionV3/default_cipher_provider.rb +159 -0
  44. data/lib/aws-sdk-s3/encryptionV3/default_key_provider.rb +35 -0
  45. data/lib/aws-sdk-s3/encryptionV3/encrypt_handler.rb +98 -0
  46. data/lib/aws-sdk-s3/encryptionV3/errors.rb +47 -0
  47. data/lib/aws-sdk-s3/encryptionV3/io_auth_decrypter.rb +60 -0
  48. data/lib/aws-sdk-s3/encryptionV3/io_decrypter.rb +35 -0
  49. data/lib/aws-sdk-s3/encryptionV3/io_encrypter.rb +84 -0
  50. data/lib/aws-sdk-s3/encryptionV3/key_provider.rb +28 -0
  51. data/lib/aws-sdk-s3/encryptionV3/kms_cipher_provider.rb +159 -0
  52. data/lib/aws-sdk-s3/encryptionV3/materials.rb +58 -0
  53. data/lib/aws-sdk-s3/encryptionV3/utils.rb +321 -0
  54. data/lib/aws-sdk-s3/encryption_v2.rb +1 -0
  55. data/lib/aws-sdk-s3/encryption_v3.rb +24 -0
  56. data/lib/aws-sdk-s3/endpoint_parameters.rb +37 -34
  57. data/lib/aws-sdk-s3/endpoint_provider.rb +572 -277
  58. data/lib/aws-sdk-s3/endpoints.rb +566 -1612
  59. data/lib/aws-sdk-s3/errors.rb +58 -0
  60. data/lib/aws-sdk-s3/express_credentials_provider.rb +27 -4
  61. data/lib/aws-sdk-s3/file_downloader.rb +192 -146
  62. data/lib/aws-sdk-s3/file_uploader.rb +10 -14
  63. data/lib/aws-sdk-s3/legacy_signer.rb +2 -1
  64. data/lib/aws-sdk-s3/multipart_download_error.rb +8 -0
  65. data/lib/aws-sdk-s3/multipart_file_uploader.rb +106 -102
  66. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +99 -108
  67. data/lib/aws-sdk-s3/multipart_upload.rb +112 -12
  68. data/lib/aws-sdk-s3/multipart_upload_error.rb +3 -4
  69. data/lib/aws-sdk-s3/multipart_upload_part.rb +55 -39
  70. data/lib/aws-sdk-s3/object.rb +713 -227
  71. data/lib/aws-sdk-s3/object_acl.rb +15 -9
  72. data/lib/aws-sdk-s3/object_copier.rb +1 -1
  73. data/lib/aws-sdk-s3/object_multipart_copier.rb +12 -9
  74. data/lib/aws-sdk-s3/object_summary.rb +592 -173
  75. data/lib/aws-sdk-s3/object_version.rb +102 -17
  76. data/lib/aws-sdk-s3/plugins/access_grants.rb +178 -0
  77. data/lib/aws-sdk-s3/plugins/checksum_algorithm.rb +31 -0
  78. data/lib/aws-sdk-s3/plugins/endpoints.rb +26 -213
  79. data/lib/aws-sdk-s3/plugins/express_session_auth.rb +19 -21
  80. data/lib/aws-sdk-s3/plugins/http_200_errors.rb +55 -18
  81. data/lib/aws-sdk-s3/plugins/md5s.rb +10 -71
  82. data/lib/aws-sdk-s3/plugins/s3_signer.rb +7 -2
  83. data/lib/aws-sdk-s3/plugins/streaming_retry.rb +5 -7
  84. data/lib/aws-sdk-s3/plugins/url_encoded_keys.rb +2 -1
  85. data/lib/aws-sdk-s3/presigner.rb +7 -5
  86. data/lib/aws-sdk-s3/resource.rb +53 -20
  87. data/lib/aws-sdk-s3/transfer_manager.rb +303 -0
  88. data/lib/aws-sdk-s3/types.rb +4738 -1542
  89. data/lib/aws-sdk-s3.rb +35 -31
  90. data/sig/bucket.rbs +231 -0
  91. data/sig/bucket_acl.rbs +78 -0
  92. data/sig/bucket_cors.rbs +69 -0
  93. data/sig/bucket_lifecycle.rbs +88 -0
  94. data/sig/bucket_lifecycle_configuration.rbs +115 -0
  95. data/sig/bucket_logging.rbs +76 -0
  96. data/sig/bucket_notification.rbs +114 -0
  97. data/sig/bucket_policy.rbs +59 -0
  98. data/sig/bucket_request_payment.rbs +54 -0
  99. data/sig/bucket_tagging.rbs +65 -0
  100. data/sig/bucket_versioning.rbs +77 -0
  101. data/sig/bucket_website.rbs +93 -0
  102. data/sig/client.rbs +2612 -0
  103. data/sig/customizations/bucket.rbs +19 -0
  104. data/sig/customizations/object.rbs +38 -0
  105. data/sig/customizations/object_summary.rbs +35 -0
  106. data/sig/errors.rbs +44 -0
  107. data/sig/multipart_upload.rbs +120 -0
  108. data/sig/multipart_upload_part.rbs +109 -0
  109. data/sig/object.rbs +464 -0
  110. data/sig/object_acl.rbs +86 -0
  111. data/sig/object_summary.rbs +347 -0
  112. data/sig/object_version.rbs +143 -0
  113. data/sig/resource.rbs +141 -0
  114. data/sig/types.rbs +2899 -0
  115. data/sig/waiters.rbs +95 -0
  116. metadata +58 -13
  117. data/lib/aws-sdk-s3/express_credentials_cache.rb +0 -30
  118. data/lib/aws-sdk-s3/plugins/skip_whole_multipart_get_checksums.rb +0 -31
@@ -62,6 +62,18 @@ module Aws::S3
62
62
  data[:checksum_algorithm]
63
63
  end
64
64
 
65
+ # The checksum type that is used to calculate the object’s checksum
66
+ # value. For more information, see [Checking object integrity][1] in the
67
+ # *Amazon S3 User Guide*.
68
+ #
69
+ #
70
+ #
71
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html
72
+ # @return [String]
73
+ def checksum_type
74
+ data[:checksum_type]
75
+ end
76
+
65
77
  # Size in bytes of the object.
66
78
  # @return [Integer]
67
79
  def size
@@ -243,7 +255,7 @@ module Aws::S3
243
255
  :retry
244
256
  end
245
257
  end
246
- Aws::Plugins::UserAgent.feature('resource') do
258
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
247
259
  Aws::Waiters::Waiter.new(options).wait({})
248
260
  end
249
261
  end
@@ -257,6 +269,9 @@ module Aws::S3
257
269
  # request_payer: "requester", # accepts requester
258
270
  # bypass_governance_retention: false,
259
271
  # expected_bucket_owner: "AccountId",
272
+ # if_match: "IfMatch",
273
+ # if_match_last_modified_time: Time.now,
274
+ # if_match_size: 1,
260
275
  # })
261
276
  # @param [Hash] options ({})
262
277
  # @option options [String] :mfa
@@ -296,6 +311,44 @@ module Aws::S3
296
311
  # The account ID of the expected bucket owner. If the account ID that
297
312
  # you provide does not match the actual owner of the bucket, the request
298
313
  # fails with the HTTP status code `403 Forbidden` (access denied).
314
+ # @option options [String] :if_match
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.
319
+ #
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.
322
+ #
323
+ # For more information about conditional requests, see [RFC 7232][1].
324
+ #
325
+ #
326
+ #
327
+ # [1]: https://tools.ietf.org/html/rfc7232
328
+ # @option options [Time,DateTime,Date,Integer,String] :if_match_last_modified_time
329
+ # If present, the object is deleted only if its modification times
330
+ # matches the provided `Timestamp`. If the `Timestamp` values do not
331
+ # match, the operation returns a `412 Precondition Failed` error. If the
332
+ # `Timestamp` matches or if the object doesn’t exist, the operation
333
+ # returns a `204 Success (No Content)` response.
334
+ #
335
+ # <note markdown="1"> This functionality is only supported for directory buckets.
336
+ #
337
+ # </note>
338
+ # @option options [Integer] :if_match_size
339
+ # If present, the object is deleted only if its size matches the
340
+ # provided size in bytes. If the `Size` value does not match, the
341
+ # operation returns a `412 Precondition Failed` error. If the `Size`
342
+ # matches or if the object doesn’t exist, the operation returns a `204
343
+ # Success (No Content)` response.
344
+ #
345
+ # <note markdown="1"> This functionality is only supported for directory buckets.
346
+ #
347
+ # </note>
348
+ #
349
+ # You can use the `If-Match`, `x-amz-if-match-last-modified-time` and
350
+ # `x-amz-if-match-size` conditional headers in conjunction with
351
+ # each-other or individually.
299
352
  # @return [Types::DeleteObjectOutput]
300
353
  def delete(options = {})
301
354
  options = options.merge(
@@ -303,7 +356,7 @@ module Aws::S3
303
356
  key: @object_key,
304
357
  version_id: @id
305
358
  )
306
- resp = Aws::Plugins::UserAgent.feature('resource') do
359
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
307
360
  @client.delete_object(options)
308
361
  end
309
362
  resp.data
@@ -530,7 +583,7 @@ module Aws::S3
530
583
  key: @object_key,
531
584
  version_id: @id
532
585
  )
533
- resp = Aws::Plugins::UserAgent.feature('resource') do
586
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
534
587
  @client.get_object(options, &block)
535
588
  end
536
589
  resp.data
@@ -544,6 +597,12 @@ module Aws::S3
544
597
  # if_none_match: "IfNoneMatch",
545
598
  # if_unmodified_since: Time.now,
546
599
  # range: "Range",
600
+ # response_cache_control: "ResponseCacheControl",
601
+ # response_content_disposition: "ResponseContentDisposition",
602
+ # response_content_encoding: "ResponseContentEncoding",
603
+ # response_content_language: "ResponseContentLanguage",
604
+ # response_content_type: "ResponseContentType",
605
+ # response_expires: Time.now,
547
606
  # sse_customer_algorithm: "SSECustomerAlgorithm",
548
607
  # sse_customer_key: "SSECustomerKey",
549
608
  # sse_customer_key_md5: "SSECustomerKeyMD5",
@@ -630,6 +689,18 @@ module Aws::S3
630
689
  # satisfiable, only the `ContentLength` is affected in the response. If
631
690
  # the Range is not satisfiable, S3 returns a `416 - Requested Range Not
632
691
  # Satisfiable` error.
692
+ # @option options [String] :response_cache_control
693
+ # Sets the `Cache-Control` header of the response.
694
+ # @option options [String] :response_content_disposition
695
+ # Sets the `Content-Disposition` header of the response.
696
+ # @option options [String] :response_content_encoding
697
+ # Sets the `Content-Encoding` header of the response.
698
+ # @option options [String] :response_content_language
699
+ # Sets the `Content-Language` header of the response.
700
+ # @option options [String] :response_content_type
701
+ # Sets the `Content-Type` header of the response.
702
+ # @option options [Time,DateTime,Date,Integer,String] :response_expires
703
+ # Sets the `Expires` header of the response.
633
704
  # @option options [String] :sse_customer_algorithm
634
705
  # Specifies the algorithm to use when encrypting the object (for
635
706
  # example, AES256).
@@ -683,10 +754,20 @@ module Aws::S3
683
754
  # @option options [String] :checksum_mode
684
755
  # To retrieve the checksum, this parameter must be enabled.
685
756
  #
686
- # In addition, if you enable `ChecksumMode` and the object is encrypted
687
- # with Amazon Web Services Key Management Service (Amazon Web Services
688
- # KMS), you must have permission to use the `kms:Decrypt` action for the
689
- # request to succeed.
757
+ # **General purpose buckets** - If you enable checksum mode and the
758
+ # object is uploaded with a [checksum][1] and encrypted with an Key
759
+ # Management Service (KMS) key, you must have permission to use the
760
+ # `kms:Decrypt` action to retrieve the checksum.
761
+ #
762
+ # **Directory buckets** - If you enable `ChecksumMode` and the object is
763
+ # encrypted with Amazon Web Services Key Management Service (Amazon Web
764
+ # Services KMS), you must also have the `kms:GenerateDataKey` and
765
+ # `kms:Decrypt` permissions in IAM identity-based policies and KMS key
766
+ # policies for the KMS key to retrieve the checksum of the object.
767
+ #
768
+ #
769
+ #
770
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_Checksum.html
690
771
  # @return [Types::HeadObjectOutput]
691
772
  def head(options = {})
692
773
  options = options.merge(
@@ -694,7 +775,7 @@ module Aws::S3
694
775
  key: @object_key,
695
776
  version_id: @id
696
777
  )
697
- resp = Aws::Plugins::UserAgent.feature('resource') do
778
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
698
779
  @client.head_object(options)
699
780
  end
700
781
  resp.data
@@ -768,7 +849,7 @@ module Aws::S3
768
849
  # request_payer: "requester", # accepts requester
769
850
  # bypass_governance_retention: false,
770
851
  # expected_bucket_owner: "AccountId",
771
- # checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256
852
+ # checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256, CRC64NVME
772
853
  # })
773
854
  # @param options ({})
774
855
  # @option options [String] :mfa
@@ -832,22 +913,23 @@ module Aws::S3
832
913
  # For the `x-amz-checksum-algorithm ` header, replace ` algorithm ` with
833
914
  # the supported algorithm from the following list:
834
915
  #
835
- # * CRC32
916
+ # * `CRC32`
917
+ #
918
+ # * `CRC32C`
836
919
  #
837
- # * CRC32C
920
+ # * `CRC64NVME`
838
921
  #
839
- # * SHA1
922
+ # * `SHA1`
840
923
  #
841
- # * SHA256
924
+ # * `SHA256`
842
925
  #
843
926
  # For more information, see [Checking object integrity][1] in the
844
927
  # *Amazon S3 User Guide*.
845
928
  #
846
929
  # If the individual checksum value you provide through
847
930
  # `x-amz-checksum-algorithm ` doesn't match the checksum algorithm you
848
- # set through `x-amz-sdk-checksum-algorithm`, Amazon S3 ignores any
849
- # provided `ChecksumAlgorithm` parameter and uses the checksum algorithm
850
- # that matches the provided value in `x-amz-checksum-algorithm `.
931
+ # set through `x-amz-sdk-checksum-algorithm`, Amazon S3 fails the
932
+ # request with a `BadDigest` error.
851
933
  #
852
934
  # If you provide an individual checksum, Amazon S3 ignores any provided
853
935
  # `ChecksumAlgorithm` parameter.
@@ -868,7 +950,7 @@ module Aws::S3
868
950
  version_id: item.id
869
951
  }
870
952
  end
871
- Aws::Plugins::UserAgent.feature('resource') do
953
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
872
954
  batch[0].client.delete_objects(params)
873
955
  end
874
956
  end
@@ -880,3 +962,6 @@ module Aws::S3
880
962
  end
881
963
  end
882
964
  end
965
+
966
+ # Load customizations if they exist
967
+ require 'aws-sdk-s3/customizations/object_version'
@@ -0,0 +1,178 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module S3
5
+ module Plugins
6
+ # @api private
7
+ class AccessGrants < Seahorse::Client::Plugin
8
+ @s3control =
9
+ begin
10
+ require 'aws-sdk-s3control'
11
+ true
12
+ rescue LoadError
13
+ false
14
+ end
15
+
16
+ option(
17
+ :access_grants,
18
+ default: false,
19
+ doc_type: 'Boolean',
20
+ docstring: <<-DOCS)
21
+ When `true`, the S3 client will use the S3 Access Grants feature to
22
+ authenticate requests. Bucket credentials will be fetched from S3
23
+ Control using the `get_data_access` API.
24
+ DOCS
25
+
26
+ option(:access_grants_credentials_provider,
27
+ doc_type: 'Aws::S3::AccessGrantsCredentialsProvider',
28
+ rbs_type: 'untyped',
29
+ docstring: <<-DOCS) do |_cfg|
30
+ When `access_grants` is `true`, this option can be used to provide
31
+ additional options to the credentials provider, including a privilege
32
+ setting, caching, and fallback behavior.
33
+ DOCS
34
+ Aws::S3::AccessGrantsCredentialsProvider.new
35
+ end
36
+
37
+ # @api private
38
+ class Handler < Seahorse::Client::Handler
39
+ PERMISSION_MAP = {
40
+ head_object: 'READ',
41
+ get_object: 'READ',
42
+ get_object_acl: 'READ',
43
+ list_multipart_uploads: 'READ',
44
+ list_objects_v2: 'READ',
45
+ list_object_versions: 'READ',
46
+ list_parts: 'READ',
47
+ head_bucket: 'READ',
48
+ get_object_attributes: 'READ',
49
+ put_object: 'WRITE',
50
+ put_object_acl: 'WRITE',
51
+ delete_object: 'WRITE',
52
+ abort_multipart_upload: 'WRITE',
53
+ create_multipart_upload: 'WRITE',
54
+ upload_part: 'WRITE',
55
+ complete_multipart_upload: 'WRITE',
56
+ delete_objects: 'WRITE',
57
+ copy_object: 'READWRITE'
58
+ }.freeze
59
+
60
+ def call(context)
61
+ provider = context.config.access_grants_credentials_provider
62
+
63
+ if access_grants_operation?(context) &&
64
+ !s3_express_endpoint?(context) &&
65
+ !credentials_head_bucket_call?(provider)
66
+ params = context[:endpoint_params]
67
+ permission = PERMISSION_MAP[context.operation_name]
68
+
69
+ key =
70
+ case context.operation_name
71
+ when :delete_objects
72
+ delete_params = context.params[:delete]
73
+ common_prefixes(delete_params[:objects].map { |o| o[:key] })
74
+ when :copy_object
75
+ source_bucket, source_key = params[:copy_source].split('/', 2)
76
+ if params[:bucket] != source_bucket
77
+ raise ArgumentError,
78
+ 'source and destination bucket must be the same'
79
+ end
80
+ common_prefixes([params[:key], source_key])
81
+ else
82
+ params[:key]
83
+ end
84
+
85
+ credentials = provider.access_grants_credentials_for(
86
+ bucket: params[:bucket],
87
+ key: key,
88
+ prefix: params[:prefix],
89
+ permission: permission
90
+ )
91
+ context[:sigv4_credentials] = credentials # Sign will use this
92
+ end
93
+
94
+ with_metric(credentials) { @handler.call(context) }
95
+ end
96
+
97
+ private
98
+
99
+ def with_metric(credentials, &block)
100
+ return block.call unless credentials
101
+
102
+ Aws::Plugins::UserAgent.metric('S3_ACCESS_GRANTS', &block)
103
+ end
104
+
105
+ # HeadBucket is a supported call. When fetching credentials,
106
+ # this plugin is executed again, and becomes recursive.
107
+ def credentials_head_bucket_call?(provider)
108
+ provider.instance_variable_get(:@head_bucket_call)
109
+ end
110
+
111
+ def access_grants_operation?(context)
112
+ params = context[:endpoint_params]
113
+ params[:bucket] && PERMISSION_MAP[context.operation_name]
114
+ end
115
+
116
+ def s3_express_endpoint?(context)
117
+ context[:endpoint_properties]['backend'] == 'S3Express'
118
+ end
119
+
120
+ # Return the common prefix of the keys, regardless of the delimiter.
121
+ # For example, given keys ['foo/bar', 'foo/baz'], the common prefix
122
+ # is 'foo/ba'.
123
+ def common_prefixes(keys)
124
+ return '' if keys.empty?
125
+
126
+ first_key = keys[0]
127
+ common_ancestor = first_key
128
+ last_prefix = ''
129
+ keys.each do |k|
130
+ until common_ancestor.empty?
131
+ break if k.start_with?(common_ancestor)
132
+
133
+ last_index = common_ancestor.rindex('/')
134
+ return '' if last_index.nil?
135
+
136
+ last_prefix = common_ancestor[(last_index + 1)..-1]
137
+ common_ancestor = common_ancestor[0...last_index]
138
+ end
139
+ end
140
+ new_common_ancestor = "#{common_ancestor}/#{last_prefix}"
141
+ keys.each do |k|
142
+ until last_prefix.empty?
143
+ break if k.start_with?(new_common_ancestor)
144
+
145
+ last_prefix = last_prefix[0...-1]
146
+ new_common_ancestor = "#{common_ancestor}/#{last_prefix}"
147
+ end
148
+ end
149
+ if new_common_ancestor == "#{first_key}/"
150
+ first_key
151
+ else
152
+ new_common_ancestor
153
+ end
154
+ end
155
+ end
156
+
157
+ def add_handlers(handlers, config)
158
+ return unless AccessGrants.s3control? && config.access_grants
159
+
160
+ handlers.add(Handler)
161
+ end
162
+
163
+ def after_initialize(client)
164
+ return unless AccessGrants.s3control? && client.config.access_grants
165
+
166
+ provider = client.config.access_grants_credentials_provider
167
+ provider.s3_client = client unless provider.s3_client
168
+ end
169
+
170
+ class << self
171
+ def s3control?
172
+ @s3control
173
+ end
174
+ end
175
+ end
176
+ end
177
+ end
178
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module S3
5
+ module Plugins
6
+ # @api private
7
+ class ChecksumAlgorithm < Seahorse::Client::Plugin
8
+
9
+ # S3 GetObject results for whole Multipart Objects contain a checksum
10
+ # that cannot be validated. These should be skipped by the
11
+ # ChecksumAlgorithm plugin.
12
+ class SkipWholeMultipartGetChecksumsHandler < Seahorse::Client::Handler
13
+ def call(context)
14
+ context[:http_checksum] ||= {}
15
+ context[:http_checksum][:skip_on_suffix] = true
16
+
17
+ @handler.call(context)
18
+ end
19
+ end
20
+
21
+ def add_handlers(handlers, _config)
22
+ handlers.add(
23
+ SkipWholeMultipartGetChecksumsHandler,
24
+ step: :initialize,
25
+ operations: [:get_object]
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end