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
@@ -14,25 +14,29 @@ module Aws::S3
14
14
  option(
15
15
  :endpoint_provider,
16
16
  doc_type: 'Aws::S3::EndpointProvider',
17
- docstring: 'The endpoint provider used to resolve endpoints. Any '\
18
- 'object that responds to `#resolve_endpoint(parameters)` '\
19
- 'where `parameters` is a Struct similar to '\
20
- '`Aws::S3::EndpointParameters`'
21
- ) do |cfg|
17
+ rbs_type: 'untyped',
18
+ docstring: <<~DOCS) do |_cfg|
19
+ The endpoint provider used to resolve endpoints. Any object that responds to
20
+ `#resolve_endpoint(parameters)` where `parameters` is a Struct similar to
21
+ `Aws::S3::EndpointParameters`.
22
+ DOCS
22
23
  Aws::S3::EndpointProvider.new
23
24
  end
24
25
 
25
26
  option(
26
27
  :disable_s3_express_session_auth,
27
- doc_type: 'Boolean',
28
- default: nil,
29
- docstring: "Parameter to indicate whether S3Express session auth should be disabled")
28
+ doc_type: 'boolean',
29
+ docstring: <<~DOCS) do |cfg|
30
+ Parameter to indicate whether S3Express session auth should be disabled
31
+ DOCS
32
+ nil
33
+ end
30
34
 
31
35
  # @api private
32
36
  class Handler < Seahorse::Client::Handler
33
37
  def call(context)
34
38
  unless context[:discovered_endpoint]
35
- params = parameters_for_operation(context)
39
+ params = Aws::S3::Endpoints.parameters_for_operation(context)
36
40
  endpoint = context.config.endpoint_provider.resolve_endpoint(params)
37
41
 
38
42
  context.http_request.endpoint = endpoint.url
@@ -45,11 +49,23 @@ module Aws::S3
45
49
  context[:auth_scheme] =
46
50
  Aws::Endpoints.resolve_auth_scheme(context, endpoint)
47
51
 
48
- @handler.call(context)
52
+ with_metrics(context) { @handler.call(context) }
49
53
  end
50
54
 
51
55
  private
52
56
 
57
+ def with_metrics(context, &block)
58
+ metrics = []
59
+ metrics << 'ENDPOINT_OVERRIDE' unless context.config.regional_endpoint
60
+ if context[:auth_scheme] && context[:auth_scheme]['name'] == 'sigv4a'
61
+ metrics << 'SIGV4A_SIGNING'
62
+ end
63
+ if context.config.credentials&.credentials&.account_id
64
+ metrics << 'RESOLVED_ACCOUNT_ID'
65
+ end
66
+ Aws::Plugins::UserAgent.metric(*metrics, &block)
67
+ end
68
+
53
69
  def apply_endpoint_headers(context, headers)
54
70
  headers.each do |key, values|
55
71
  value = values
@@ -60,209 +76,6 @@ module Aws::S3
60
76
  context.http_request.headers[key] = value
61
77
  end
62
78
  end
63
-
64
- def parameters_for_operation(context)
65
- case context.operation_name
66
- when :abort_multipart_upload
67
- Aws::S3::Endpoints::AbortMultipartUpload.build(context)
68
- when :complete_multipart_upload
69
- Aws::S3::Endpoints::CompleteMultipartUpload.build(context)
70
- when :copy_object
71
- Aws::S3::Endpoints::CopyObject.build(context)
72
- when :create_bucket
73
- Aws::S3::Endpoints::CreateBucket.build(context)
74
- when :create_multipart_upload
75
- Aws::S3::Endpoints::CreateMultipartUpload.build(context)
76
- when :create_session
77
- Aws::S3::Endpoints::CreateSession.build(context)
78
- when :delete_bucket
79
- Aws::S3::Endpoints::DeleteBucket.build(context)
80
- when :delete_bucket_analytics_configuration
81
- Aws::S3::Endpoints::DeleteBucketAnalyticsConfiguration.build(context)
82
- when :delete_bucket_cors
83
- Aws::S3::Endpoints::DeleteBucketCors.build(context)
84
- when :delete_bucket_encryption
85
- Aws::S3::Endpoints::DeleteBucketEncryption.build(context)
86
- when :delete_bucket_intelligent_tiering_configuration
87
- Aws::S3::Endpoints::DeleteBucketIntelligentTieringConfiguration.build(context)
88
- when :delete_bucket_inventory_configuration
89
- Aws::S3::Endpoints::DeleteBucketInventoryConfiguration.build(context)
90
- when :delete_bucket_lifecycle
91
- Aws::S3::Endpoints::DeleteBucketLifecycle.build(context)
92
- when :delete_bucket_metrics_configuration
93
- Aws::S3::Endpoints::DeleteBucketMetricsConfiguration.build(context)
94
- when :delete_bucket_ownership_controls
95
- Aws::S3::Endpoints::DeleteBucketOwnershipControls.build(context)
96
- when :delete_bucket_policy
97
- Aws::S3::Endpoints::DeleteBucketPolicy.build(context)
98
- when :delete_bucket_replication
99
- Aws::S3::Endpoints::DeleteBucketReplication.build(context)
100
- when :delete_bucket_tagging
101
- Aws::S3::Endpoints::DeleteBucketTagging.build(context)
102
- when :delete_bucket_website
103
- Aws::S3::Endpoints::DeleteBucketWebsite.build(context)
104
- when :delete_object
105
- Aws::S3::Endpoints::DeleteObject.build(context)
106
- when :delete_object_tagging
107
- Aws::S3::Endpoints::DeleteObjectTagging.build(context)
108
- when :delete_objects
109
- Aws::S3::Endpoints::DeleteObjects.build(context)
110
- when :delete_public_access_block
111
- Aws::S3::Endpoints::DeletePublicAccessBlock.build(context)
112
- when :get_bucket_accelerate_configuration
113
- Aws::S3::Endpoints::GetBucketAccelerateConfiguration.build(context)
114
- when :get_bucket_acl
115
- Aws::S3::Endpoints::GetBucketAcl.build(context)
116
- when :get_bucket_analytics_configuration
117
- Aws::S3::Endpoints::GetBucketAnalyticsConfiguration.build(context)
118
- when :get_bucket_cors
119
- Aws::S3::Endpoints::GetBucketCors.build(context)
120
- when :get_bucket_encryption
121
- Aws::S3::Endpoints::GetBucketEncryption.build(context)
122
- when :get_bucket_intelligent_tiering_configuration
123
- Aws::S3::Endpoints::GetBucketIntelligentTieringConfiguration.build(context)
124
- when :get_bucket_inventory_configuration
125
- Aws::S3::Endpoints::GetBucketInventoryConfiguration.build(context)
126
- when :get_bucket_lifecycle
127
- Aws::S3::Endpoints::GetBucketLifecycle.build(context)
128
- when :get_bucket_lifecycle_configuration
129
- Aws::S3::Endpoints::GetBucketLifecycleConfiguration.build(context)
130
- when :get_bucket_location
131
- Aws::S3::Endpoints::GetBucketLocation.build(context)
132
- when :get_bucket_logging
133
- Aws::S3::Endpoints::GetBucketLogging.build(context)
134
- when :get_bucket_metrics_configuration
135
- Aws::S3::Endpoints::GetBucketMetricsConfiguration.build(context)
136
- when :get_bucket_notification
137
- Aws::S3::Endpoints::GetBucketNotification.build(context)
138
- when :get_bucket_notification_configuration
139
- Aws::S3::Endpoints::GetBucketNotificationConfiguration.build(context)
140
- when :get_bucket_ownership_controls
141
- Aws::S3::Endpoints::GetBucketOwnershipControls.build(context)
142
- when :get_bucket_policy
143
- Aws::S3::Endpoints::GetBucketPolicy.build(context)
144
- when :get_bucket_policy_status
145
- Aws::S3::Endpoints::GetBucketPolicyStatus.build(context)
146
- when :get_bucket_replication
147
- Aws::S3::Endpoints::GetBucketReplication.build(context)
148
- when :get_bucket_request_payment
149
- Aws::S3::Endpoints::GetBucketRequestPayment.build(context)
150
- when :get_bucket_tagging
151
- Aws::S3::Endpoints::GetBucketTagging.build(context)
152
- when :get_bucket_versioning
153
- Aws::S3::Endpoints::GetBucketVersioning.build(context)
154
- when :get_bucket_website
155
- Aws::S3::Endpoints::GetBucketWebsite.build(context)
156
- when :get_object
157
- Aws::S3::Endpoints::GetObject.build(context)
158
- when :get_object_acl
159
- Aws::S3::Endpoints::GetObjectAcl.build(context)
160
- when :get_object_attributes
161
- Aws::S3::Endpoints::GetObjectAttributes.build(context)
162
- when :get_object_legal_hold
163
- Aws::S3::Endpoints::GetObjectLegalHold.build(context)
164
- when :get_object_lock_configuration
165
- Aws::S3::Endpoints::GetObjectLockConfiguration.build(context)
166
- when :get_object_retention
167
- Aws::S3::Endpoints::GetObjectRetention.build(context)
168
- when :get_object_tagging
169
- Aws::S3::Endpoints::GetObjectTagging.build(context)
170
- when :get_object_torrent
171
- Aws::S3::Endpoints::GetObjectTorrent.build(context)
172
- when :get_public_access_block
173
- Aws::S3::Endpoints::GetPublicAccessBlock.build(context)
174
- when :head_bucket
175
- Aws::S3::Endpoints::HeadBucket.build(context)
176
- when :head_object
177
- Aws::S3::Endpoints::HeadObject.build(context)
178
- when :list_bucket_analytics_configurations
179
- Aws::S3::Endpoints::ListBucketAnalyticsConfigurations.build(context)
180
- when :list_bucket_intelligent_tiering_configurations
181
- Aws::S3::Endpoints::ListBucketIntelligentTieringConfigurations.build(context)
182
- when :list_bucket_inventory_configurations
183
- Aws::S3::Endpoints::ListBucketInventoryConfigurations.build(context)
184
- when :list_bucket_metrics_configurations
185
- Aws::S3::Endpoints::ListBucketMetricsConfigurations.build(context)
186
- when :list_buckets
187
- Aws::S3::Endpoints::ListBuckets.build(context)
188
- when :list_directory_buckets
189
- Aws::S3::Endpoints::ListDirectoryBuckets.build(context)
190
- when :list_multipart_uploads
191
- Aws::S3::Endpoints::ListMultipartUploads.build(context)
192
- when :list_object_versions
193
- Aws::S3::Endpoints::ListObjectVersions.build(context)
194
- when :list_objects
195
- Aws::S3::Endpoints::ListObjects.build(context)
196
- when :list_objects_v2
197
- Aws::S3::Endpoints::ListObjectsV2.build(context)
198
- when :list_parts
199
- Aws::S3::Endpoints::ListParts.build(context)
200
- when :put_bucket_accelerate_configuration
201
- Aws::S3::Endpoints::PutBucketAccelerateConfiguration.build(context)
202
- when :put_bucket_acl
203
- Aws::S3::Endpoints::PutBucketAcl.build(context)
204
- when :put_bucket_analytics_configuration
205
- Aws::S3::Endpoints::PutBucketAnalyticsConfiguration.build(context)
206
- when :put_bucket_cors
207
- Aws::S3::Endpoints::PutBucketCors.build(context)
208
- when :put_bucket_encryption
209
- Aws::S3::Endpoints::PutBucketEncryption.build(context)
210
- when :put_bucket_intelligent_tiering_configuration
211
- Aws::S3::Endpoints::PutBucketIntelligentTieringConfiguration.build(context)
212
- when :put_bucket_inventory_configuration
213
- Aws::S3::Endpoints::PutBucketInventoryConfiguration.build(context)
214
- when :put_bucket_lifecycle
215
- Aws::S3::Endpoints::PutBucketLifecycle.build(context)
216
- when :put_bucket_lifecycle_configuration
217
- Aws::S3::Endpoints::PutBucketLifecycleConfiguration.build(context)
218
- when :put_bucket_logging
219
- Aws::S3::Endpoints::PutBucketLogging.build(context)
220
- when :put_bucket_metrics_configuration
221
- Aws::S3::Endpoints::PutBucketMetricsConfiguration.build(context)
222
- when :put_bucket_notification
223
- Aws::S3::Endpoints::PutBucketNotification.build(context)
224
- when :put_bucket_notification_configuration
225
- Aws::S3::Endpoints::PutBucketNotificationConfiguration.build(context)
226
- when :put_bucket_ownership_controls
227
- Aws::S3::Endpoints::PutBucketOwnershipControls.build(context)
228
- when :put_bucket_policy
229
- Aws::S3::Endpoints::PutBucketPolicy.build(context)
230
- when :put_bucket_replication
231
- Aws::S3::Endpoints::PutBucketReplication.build(context)
232
- when :put_bucket_request_payment
233
- Aws::S3::Endpoints::PutBucketRequestPayment.build(context)
234
- when :put_bucket_tagging
235
- Aws::S3::Endpoints::PutBucketTagging.build(context)
236
- when :put_bucket_versioning
237
- Aws::S3::Endpoints::PutBucketVersioning.build(context)
238
- when :put_bucket_website
239
- Aws::S3::Endpoints::PutBucketWebsite.build(context)
240
- when :put_object
241
- Aws::S3::Endpoints::PutObject.build(context)
242
- when :put_object_acl
243
- Aws::S3::Endpoints::PutObjectAcl.build(context)
244
- when :put_object_legal_hold
245
- Aws::S3::Endpoints::PutObjectLegalHold.build(context)
246
- when :put_object_lock_configuration
247
- Aws::S3::Endpoints::PutObjectLockConfiguration.build(context)
248
- when :put_object_retention
249
- Aws::S3::Endpoints::PutObjectRetention.build(context)
250
- when :put_object_tagging
251
- Aws::S3::Endpoints::PutObjectTagging.build(context)
252
- when :put_public_access_block
253
- Aws::S3::Endpoints::PutPublicAccessBlock.build(context)
254
- when :restore_object
255
- Aws::S3::Endpoints::RestoreObject.build(context)
256
- when :select_object_content
257
- Aws::S3::Endpoints::SelectObjectContent.build(context)
258
- when :upload_part
259
- Aws::S3::Endpoints::UploadPart.build(context)
260
- when :upload_part_copy
261
- Aws::S3::Endpoints::UploadPartCopy.build(context)
262
- when :write_get_object_response
263
- Aws::S3::Endpoints::WriteGetObjectResponse.build(context)
264
- end
265
- end
266
79
  end
267
80
 
268
81
  def add_handlers(handlers, _config)
@@ -18,6 +18,7 @@ When `true`, S3 Express session authentication is disabled.
18
18
 
19
19
  option(:express_credentials_provider,
20
20
  doc_type: 'Aws::S3::ExpressCredentialsProvider',
21
+ rbs_type: 'untyped',
21
22
  docstring: <<-DOCS) do |_cfg|
22
23
  Credential Provider for S3 Express endpoints. Manages credentials
23
24
  for different buckets.
@@ -28,33 +29,30 @@ for different buckets.
28
29
  # @api private
29
30
  class Handler < Seahorse::Client::Handler
30
31
  def call(context)
31
- if (props = context[:endpoint_properties])
32
- # S3 Express endpoint - turn off md5 and enable crc32 default
33
- if (backend = props['backend']) && backend == 'S3Express'
34
- if context.operation_name == :put_object || checksum_required?(context)
35
- context[:default_request_checksum_algorithm] = 'CRC32'
36
- end
37
- context[:s3_express_endpoint] = true
38
- end
32
+ context[:s3_express_endpoint] = true if s3_express_endpoint?(context)
39
33
 
40
- # if s3 express auth, use new credentials and sign additional header
41
- if context[:auth_scheme]['name'] == 'sigv4-s3express' &&
42
- !context.config.disable_s3_express_session_auth
43
- bucket = context.params[:bucket]
44
- credentials_provider = context.config.express_credentials_provider
45
- credentials = credentials_provider.express_credentials_for(bucket)
46
- context[:sigv4_credentials] = credentials # Sign will use this
47
- end
34
+ # if s3 express auth, use new credentials and sign additional header
35
+ if context[:auth_scheme]['name'] == 'sigv4-s3express' &&
36
+ !context.config.disable_s3_express_session_auth
37
+ bucket = context.params[:bucket]
38
+ credentials_provider = context.config.express_credentials_provider
39
+ credentials = credentials_provider.express_credentials_for(bucket)
40
+ context[:sigv4_credentials] = credentials # Sign will use this
48
41
  end
49
- @handler.call(context)
42
+
43
+ with_metric(credentials) { @handler.call(context) }
50
44
  end
51
45
 
52
46
  private
53
47
 
54
- def checksum_required?(context)
55
- context.operation.http_checksum_required ||
56
- (context.operation.http_checksum &&
57
- context.operation.http_checksum['requestChecksumRequired'])
48
+ def with_metric(credentials, &block)
49
+ return block.call unless credentials
50
+
51
+ Aws::Plugins::UserAgent.metric('S3_EXPRESS_BUCKET', &block)
52
+ end
53
+
54
+ def s3_express_endpoint?(context)
55
+ context[:endpoint_properties]['backend'] == 'S3Express'
58
56
  end
59
57
  end
60
58
 
@@ -15,22 +15,67 @@ module Aws
15
15
 
16
16
  def call(context)
17
17
  @handler.call(context).on(200) do |response|
18
- if error = check_for_error(context)
19
- context.http_response.status_code = 500
20
- response.data = nil
21
- response.error = error
18
+ return response if streaming_output?(context.operation.output)
19
+
20
+ error = check_for_error(context)
21
+ return response unless error
22
+
23
+ context.http_response.status_code = 500
24
+ response.data = nil
25
+ response.error = error
26
+ end
27
+ end
28
+
29
+ private
30
+
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
39
+ end
40
+ end
41
+
42
+ # Checks if the output shape is a structure shape and has members that
43
+ # are in the body for the case of a payload and a normal structure. A
44
+ # non-structure shape will not have members in the body. In the case
45
+ # of a string or blob, the body contents would have been checked first
46
+ # before this method is called in incomplete_xml_body?.
47
+ def members_in_body?(output)
48
+ shape =
49
+ if output[:payload_member]
50
+ output[:payload_member].shape
51
+ else
52
+ output.shape
22
53
  end
54
+
55
+ if structure_shape?(shape)
56
+ shape.members.any? { |_, k| k.location.nil? }
57
+ else
58
+ false
23
59
  end
24
60
  end
25
61
 
62
+ def structure_shape?(shape)
63
+ shape.is_a?(Seahorse::Model::Shapes::StructureShape)
64
+ end
65
+
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/)
70
+ end
71
+
26
72
  def check_for_error(context)
27
73
  xml = context.http_response.body_contents
28
- if xml.match(/<Error>/)
29
- error_code = xml.match(/<Code>(.+?)<\/Code>/)[1]
30
- error_message = xml.match(/<Message>(.+?)<\/Message>/)[1]
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]
31
77
  S3::Errors.error_class(error_code).new(context, error_message)
32
- elsif !xml.match(/<\w/) # Must have the start of an XML Tag
33
- # Other incomplete xml bodies will result in XML ParsingError
78
+ elsif incomplete_xml_body?(xml, context.operation.output)
34
79
  Seahorse::Client::NetworkingError.new(
35
80
  S3::Errors
36
81
  .error_class('InternalError')
@@ -40,15 +85,7 @@ module Aws
40
85
  end
41
86
  end
42
87
 
43
- handler(
44
- Handler,
45
- step: :sign,
46
- operations: [
47
- :complete_multipart_upload,
48
- :copy_object,
49
- :upload_part_copy,
50
- ]
51
- )
88
+ handler(Handler, step: :sign)
52
89
  end
53
90
  end
54
91
  end
@@ -6,81 +6,20 @@ module Aws
6
6
  module S3
7
7
  module Plugins
8
8
  # @api private
9
- # This plugin is effectively deprecated in favor of modeled
9
+ # This plugin is deprecated in favor of modeled
10
10
  # httpChecksumRequired traits.
11
11
  class Md5s < Seahorse::Client::Plugin
12
- # These operations allow Content MD5 but are not required by
13
- # httpChecksumRequired. This list should not grow.
14
- OPTIONAL_OPERATIONS = [
15
- :put_object,
16
- :upload_part
17
- ]
18
-
19
- # @api private
20
- class Handler < Seahorse::Client::Handler
21
-
22
- CHUNK_SIZE = 1 * 1024 * 1024 # one MB
23
-
24
- def call(context)
25
- if !context[:checksum_algorithms] && # skip in favor of flexible checksum
26
- !context[:s3_express_endpoint] # s3 express endpoints do not support md5
27
- body = context.http_request.body
28
- if body.respond_to?(:size) && body.size > 0
29
- context.http_request.headers['Content-Md5'] ||= md5(body)
30
- end
31
- end
32
- @handler.call(context)
33
- end
34
-
35
- private
36
-
37
- # @param [File, Tempfile, IO#read, String] value
38
- # @return [String<MD5>]
39
- def md5(value)
40
- if (File === value || Tempfile === value) && !value.path.nil? && File.exist?(value.path)
41
- OpenSSL::Digest::MD5.file(value).base64digest
42
- elsif value.respond_to?(:read)
43
- md5 = OpenSSL::Digest::MD5.new
44
- update_in_chunks(md5, value)
45
- md5.base64digest
46
- else
47
- OpenSSL::Digest::MD5.digest(value).base64digest
48
- end
49
- end
50
-
51
- def update_in_chunks(digest, io)
52
- loop do
53
- chunk = io.read(CHUNK_SIZE)
54
- break unless chunk
55
- digest.update(chunk)
56
- end
57
- io.rewind
58
- end
59
-
60
- end
61
-
62
12
  option(:compute_checksums,
63
- default: true,
64
- doc_type: 'Boolean',
65
- docstring: <<-DOCS)
66
- When `true` a MD5 checksum will be computed and sent in the Content Md5
67
- header for :put_object and :upload_part. When `false`, MD5 checksums
68
- will not be computed for these operations. Checksums are still computed
69
- for operations requiring them. Checksum errors returned by Amazon S3 are
70
- automatically retried up to `:retry_limit` times.
71
- DOCS
72
-
73
- def add_handlers(handlers, config)
74
- if config.compute_checksums
75
- # priority set low to ensure md5 is computed AFTER the request is
76
- # built but before it is signed
77
- handlers.add(
78
- Handler,
79
- priority: 10, step: :build, operations: OPTIONAL_OPERATIONS
80
- )
81
- end
13
+ default: true,
14
+ doc_type: 'Boolean',
15
+ docstring: <<~DOCS)
16
+ This option is deprecated. Please use `:request_checksum_calculation` instead.
17
+ When `false`, `request_checksum_calculation` is overridden to `when_required`.
18
+ DOCS
19
+
20
+ def after_initialize(client)
21
+ client.config.request_checksum_calculation = 'when_required' unless client.config.compute_checksums
82
22
  end
83
-
84
23
  end
85
24
  end
86
25
  end
@@ -4,6 +4,11 @@ require 'aws-sigv4'
4
4
 
5
5
  module Aws
6
6
  module S3
7
+ # @api private
8
+ def self.bucket_region_cache
9
+ @bucket_region_cache ||= BucketRegionCache.new
10
+ end
11
+
7
12
  module Plugins
8
13
  # This plugin used to have a V4 signer but it was removed in favor of
9
14
  # generic Sign plugin that uses endpoint auth scheme.
@@ -51,7 +56,7 @@ module Aws
51
56
  private
52
57
 
53
58
  def check_for_cached_region(context, bucket)
54
- cached_region = S3::BUCKET_REGIONS[bucket]
59
+ cached_region = Aws::S3.bucket_region_cache[bucket]
55
60
  if cached_region &&
56
61
  cached_region != context.config.region &&
57
62
  !S3Signer.custom_endpoint?(context)
@@ -97,7 +102,7 @@ module Aws
97
102
  end
98
103
 
99
104
  def update_bucket_cache(context, actual_region)
100
- S3::BUCKET_REGIONS[context.params[:bucket]] = actual_region
105
+ Aws::S3.bucket_region_cache[context.params[:bucket]] = actual_region
101
106
  end
102
107
 
103
108
  def fips_region?(resp)
@@ -62,18 +62,16 @@ module Aws
62
62
  class Handler < Seahorse::Client::Handler
63
63
 
64
64
  def call(context)
65
- target = context.params[:response_target] || context[:response_target]
66
-
67
65
  # retry is only supported when range is NOT set on the initial request
68
- if supported_target?(target) && !context.params[:range]
69
- add_event_listeners(context, target)
66
+ if supported_target?(context) && !context.params[:range]
67
+ add_event_listeners(context)
70
68
  end
71
69
  @handler.call(context)
72
70
  end
73
71
 
74
72
  private
75
73
 
76
- def add_event_listeners(context, target)
74
+ def add_event_listeners(context)
77
75
  context.http_response.on_headers(200..299) do
78
76
  case context.http_response.body
79
77
  when Seahorse::Client::BlockIO then
@@ -123,8 +121,8 @@ module Aws
123
121
  context.http_response.body.is_a?(RetryableManagedFile)
124
122
  end
125
123
 
126
- def supported_target?(target)
127
- case target
124
+ def supported_target?(context)
125
+ case context[:response_target]
128
126
  when Proc, String, Pathname then true
129
127
  else false
130
128
  end
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'uri'
4
- require 'cgi'
4
+ require "cgi/escape"
5
+ require "cgi/util" if RUBY_VERSION < "3.5"
5
6
 
6
7
  module Aws
7
8
  module S3
@@ -193,13 +193,14 @@ module Aws
193
193
  req, expires_in, secure, time, unsigned_headers, hoist = true
194
194
  )
195
195
  x_amz_headers = {}
196
-
197
196
  http_req = req.context.http_request
198
-
199
- req.handlers.remove(Aws::S3::Plugins::S3Signer::LegacyHandler)
200
- req.handlers.remove(Aws::Plugins::Sign::Handler)
201
197
  req.handlers.remove(Seahorse::Client::Plugins::ContentLength::Handler)
202
-
198
+ req.handlers.remove(Aws::Rest::ContentTypeHandler)
199
+ req.handlers.remove(Aws::Plugins::ChecksumAlgorithm::OptionHandler)
200
+ req.handlers.remove(Aws::Plugins::ChecksumAlgorithm::ChecksumHandler)
201
+ req.handlers.remove(Aws::Plugins::InvocationId::Handler)
202
+ req.handlers.remove(Aws::Plugins::Sign::Handler)
203
+ req.handlers.remove(Aws::S3::Plugins::S3Signer::LegacyHandler)
203
204
  req.handle(step: :send) do |context|
204
205
  # if an endpoint was not provided, force secure or insecure
205
206
  if context.config.regional_endpoint
@@ -236,6 +237,7 @@ module Aws
236
237
  credentials_provider: context[:sigv4_credentials] || context.config.credentials,
237
238
  signing_algorithm: scheme_name.to_sym,
238
239
  uri_escape_path: !!!auth_scheme['disableDoubleEncoding'],
240
+ normalize_path: !!!auth_scheme['disableNormalizePath'],
239
241
  unsigned_headers: unsigned_headers,
240
242
  apply_checksum_header: false
241
243
  )