aws-sdk-s3 1.177.0 → 1.178.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-s3/bucket.rb +38 -24
- data/lib/aws-sdk-s3/bucket_acl.rb +5 -4
- data/lib/aws-sdk-s3/bucket_cors.rb +5 -4
- data/lib/aws-sdk-s3/bucket_lifecycle.rb +1 -1
- data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +2 -2
- data/lib/aws-sdk-s3/bucket_logging.rb +1 -1
- data/lib/aws-sdk-s3/bucket_policy.rb +9 -8
- data/lib/aws-sdk-s3/bucket_request_payment.rb +2 -2
- data/lib/aws-sdk-s3/bucket_tagging.rb +2 -2
- data/lib/aws-sdk-s3/bucket_versioning.rb +6 -6
- data/lib/aws-sdk-s3/bucket_website.rb +2 -2
- data/lib/aws-sdk-s3/client.rb +379 -237
- data/lib/aws-sdk-s3/client_api.rb +34 -2
- data/lib/aws-sdk-s3/file_downloader.rb +4 -21
- data/lib/aws-sdk-s3/multipart_file_uploader.rb +31 -13
- data/lib/aws-sdk-s3/multipart_upload.rb +48 -6
- data/lib/aws-sdk-s3/multipart_upload_part.rb +52 -36
- data/lib/aws-sdk-s3/object.rb +108 -58
- data/lib/aws-sdk-s3/object_acl.rb +4 -4
- data/lib/aws-sdk-s3/object_summary.rb +63 -28
- data/lib/aws-sdk-s3/object_version.rb +21 -8
- data/lib/aws-sdk-s3/plugins/checksum_algorithm.rb +31 -0
- data/lib/aws-sdk-s3/plugins/express_session_auth.rb +11 -20
- data/lib/aws-sdk-s3/plugins/md5s.rb +10 -71
- data/lib/aws-sdk-s3/presigner.rb +4 -5
- data/lib/aws-sdk-s3/types.rb +734 -416
- data/lib/aws-sdk-s3.rb +1 -1
- data/sig/bucket.rbs +3 -2
- data/sig/bucket_acl.rbs +1 -1
- data/sig/bucket_cors.rbs +1 -1
- data/sig/bucket_lifecycle.rbs +1 -1
- data/sig/bucket_lifecycle_configuration.rbs +1 -1
- data/sig/bucket_logging.rbs +1 -1
- data/sig/bucket_policy.rbs +1 -1
- data/sig/bucket_request_payment.rbs +1 -1
- data/sig/bucket_tagging.rbs +1 -1
- data/sig/bucket_versioning.rbs +3 -3
- data/sig/bucket_website.rbs +1 -1
- data/sig/client.rbs +50 -29
- data/sig/multipart_upload.rbs +8 -1
- data/sig/multipart_upload_part.rbs +5 -1
- data/sig/object.rbs +13 -5
- data/sig/object_acl.rbs +1 -1
- data/sig/object_summary.rbs +11 -6
- data/sig/object_version.rbs +5 -2
- data/sig/resource.rbs +2 -0
- data/sig/types.rbs +61 -32
- metadata +5 -5
- data/lib/aws-sdk-s3/plugins/skip_whole_multipart_get_checksums.rb +0 -31
@@ -84,6 +84,18 @@ module Aws::S3
|
|
84
84
|
data[:checksum_algorithm]
|
85
85
|
end
|
86
86
|
|
87
|
+
# The checksum type that is used to calculate the object’s checksum
|
88
|
+
# value. For more information, see [Checking object integrity][1] in the
|
89
|
+
# *Amazon S3 User Guide*.
|
90
|
+
#
|
91
|
+
#
|
92
|
+
#
|
93
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html
|
94
|
+
# @return [String]
|
95
|
+
def checksum_type
|
96
|
+
data[:checksum_type]
|
97
|
+
end
|
98
|
+
|
87
99
|
# Size in bytes of the object
|
88
100
|
# @return [Integer]
|
89
101
|
def size
|
@@ -324,7 +336,7 @@ module Aws::S3
|
|
324
336
|
# object_summary.copy_from({
|
325
337
|
# acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
|
326
338
|
# cache_control: "CacheControl",
|
327
|
-
# checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256
|
339
|
+
# checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256, CRC64NVME
|
328
340
|
# content_disposition: "ContentDisposition",
|
329
341
|
# content_encoding: "ContentEncoding",
|
330
342
|
# content_language: "ContentLanguage",
|
@@ -1458,7 +1470,8 @@ module Aws::S3
|
|
1458
1470
|
# object_lock_retain_until_date: Time.now,
|
1459
1471
|
# object_lock_legal_hold_status: "ON", # accepts ON, OFF
|
1460
1472
|
# expected_bucket_owner: "AccountId",
|
1461
|
-
# checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256
|
1473
|
+
# checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256, CRC64NVME
|
1474
|
+
# checksum_type: "COMPOSITE", # accepts COMPOSITE, FULL_OBJECT
|
1462
1475
|
# })
|
1463
1476
|
# @param [Hash] options ({})
|
1464
1477
|
# @option options [String] :acl
|
@@ -1894,7 +1907,7 @@ module Aws::S3
|
|
1894
1907
|
# [2]: https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-managed-cmk
|
1895
1908
|
# @option options [String] :ssekms_encryption_context
|
1896
1909
|
# Specifies the Amazon Web Services KMS Encryption Context to use for
|
1897
|
-
# object encryption. The value of this header is a Base64
|
1910
|
+
# object encryption. The value of this header is a Base64 encoded string
|
1898
1911
|
# of a UTF-8 encoded JSON, which contains the encryption context as
|
1899
1912
|
# key-value pairs.
|
1900
1913
|
#
|
@@ -1983,6 +1996,14 @@ module Aws::S3
|
|
1983
1996
|
#
|
1984
1997
|
#
|
1985
1998
|
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html
|
1999
|
+
# @option options [String] :checksum_type
|
2000
|
+
# Indicates the checksum type that you want Amazon S3 to use to
|
2001
|
+
# calculate the object’s checksum value. For more information, see
|
2002
|
+
# [Checking object integrity in the Amazon S3 User Guide][1].
|
2003
|
+
#
|
2004
|
+
#
|
2005
|
+
#
|
2006
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html
|
1986
2007
|
# @return [MultipartUpload]
|
1987
2008
|
def initiate_multipart_upload(options = {})
|
1988
2009
|
options = options.merge(
|
@@ -2012,9 +2033,10 @@ module Aws::S3
|
|
2012
2033
|
# content_length: 1,
|
2013
2034
|
# content_md5: "ContentMD5",
|
2014
2035
|
# content_type: "ContentType",
|
2015
|
-
# checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256
|
2036
|
+
# checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256, CRC64NVME
|
2016
2037
|
# checksum_crc32: "ChecksumCRC32",
|
2017
2038
|
# checksum_crc32c: "ChecksumCRC32C",
|
2039
|
+
# checksum_crc64nvme: "ChecksumCRC64NVME",
|
2018
2040
|
# checksum_sha1: "ChecksumSHA1",
|
2019
2041
|
# checksum_sha256: "ChecksumSHA256",
|
2020
2042
|
# expires: Time.now,
|
@@ -2120,7 +2142,7 @@ module Aws::S3
|
|
2120
2142
|
#
|
2121
2143
|
# [1]: https://www.rfc-editor.org/rfc/rfc9110.html#name-content-length
|
2122
2144
|
# @option options [String] :content_md5
|
2123
|
-
# The
|
2145
|
+
# The Base64 encoded 128-bit `MD5` digest of the message (without the
|
2124
2146
|
# headers) according to RFC 1864. This header can be used as a message
|
2125
2147
|
# integrity check to verify that the data is the same data that was
|
2126
2148
|
# originally sent. Although it is optional, we recommend using the
|
@@ -2163,22 +2185,23 @@ module Aws::S3
|
|
2163
2185
|
# For the `x-amz-checksum-algorithm ` header, replace ` algorithm ` with
|
2164
2186
|
# the supported algorithm from the following list:
|
2165
2187
|
#
|
2166
|
-
# * `
|
2188
|
+
# * `CRC-32`
|
2167
2189
|
#
|
2168
|
-
# * `
|
2190
|
+
# * `CRC-32C`
|
2169
2191
|
#
|
2170
|
-
# * `
|
2192
|
+
# * `CRC-64NVME`
|
2171
2193
|
#
|
2172
|
-
# * `
|
2194
|
+
# * `SHA-1`
|
2195
|
+
#
|
2196
|
+
# * `SHA-256`
|
2173
2197
|
#
|
2174
2198
|
# For more information, see [Checking object integrity][1] in the
|
2175
2199
|
# *Amazon S3 User Guide*.
|
2176
2200
|
#
|
2177
2201
|
# If the individual checksum value you provide through
|
2178
2202
|
# `x-amz-checksum-algorithm ` doesn't match the checksum algorithm you
|
2179
|
-
# set through `x-amz-sdk-checksum-algorithm`, Amazon S3
|
2180
|
-
#
|
2181
|
-
# that matches the provided value in `x-amz-checksum-algorithm `.
|
2203
|
+
# set through `x-amz-sdk-checksum-algorithm`, Amazon S3 fails the
|
2204
|
+
# request with a `BadDigest` error.
|
2182
2205
|
#
|
2183
2206
|
# <note markdown="1"> The `Content-MD5` or `x-amz-sdk-checksum-algorithm` header is required
|
2184
2207
|
# for any request to upload an object with a retention period configured
|
@@ -2198,7 +2221,7 @@ module Aws::S3
|
|
2198
2221
|
# @option options [String] :checksum_crc32
|
2199
2222
|
# This header can be used as a data integrity check to verify that the
|
2200
2223
|
# data received is the same data that was originally sent. This header
|
2201
|
-
# specifies the
|
2224
|
+
# specifies the Base64 encoded, 32-bit `CRC-32` checksum of the object.
|
2202
2225
|
# For more information, see [Checking object integrity][1] in the
|
2203
2226
|
# *Amazon S3 User Guide*.
|
2204
2227
|
#
|
@@ -2208,19 +2231,30 @@ module Aws::S3
|
|
2208
2231
|
# @option options [String] :checksum_crc32c
|
2209
2232
|
# This header can be used as a data integrity check to verify that the
|
2210
2233
|
# data received is the same data that was originally sent. This header
|
2211
|
-
# specifies the
|
2234
|
+
# specifies the Base64 encoded, 32-bit `CRC-32C` checksum of the object.
|
2212
2235
|
# For more information, see [Checking object integrity][1] in the
|
2213
2236
|
# *Amazon S3 User Guide*.
|
2214
2237
|
#
|
2215
2238
|
#
|
2216
2239
|
#
|
2217
2240
|
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html
|
2241
|
+
# @option options [String] :checksum_crc64nvme
|
2242
|
+
# This header can be used as a data integrity check to verify that the
|
2243
|
+
# data received is the same data that was originally sent. This header
|
2244
|
+
# specifies the Base64 encoded, 64-bit `CRC-64NVME` checksum of the
|
2245
|
+
# object. The `CRC-64NVME` checksum is always a full object checksum.
|
2246
|
+
# For more information, see [Checking object integrity in the Amazon S3
|
2247
|
+
# User Guide][1].
|
2248
|
+
#
|
2249
|
+
#
|
2250
|
+
#
|
2251
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html
|
2218
2252
|
# @option options [String] :checksum_sha1
|
2219
2253
|
# This header can be used as a data integrity check to verify that the
|
2220
2254
|
# data received is the same data that was originally sent. This header
|
2221
|
-
# specifies the
|
2222
|
-
# more information, see [Checking object integrity][1] in the
|
2223
|
-
# User Guide*.
|
2255
|
+
# specifies the Base64 encoded, 160-bit `SHA-1` digest of the object.
|
2256
|
+
# For more information, see [Checking object integrity][1] in the
|
2257
|
+
# *Amazon S3 User Guide*.
|
2224
2258
|
#
|
2225
2259
|
#
|
2226
2260
|
#
|
@@ -2228,7 +2262,7 @@ module Aws::S3
|
|
2228
2262
|
# @option options [String] :checksum_sha256
|
2229
2263
|
# This header can be used as a data integrity check to verify that the
|
2230
2264
|
# data received is the same data that was originally sent. This header
|
2231
|
-
# specifies the
|
2265
|
+
# specifies the Base64 encoded, 256-bit `SHA-256` digest of the object.
|
2232
2266
|
# For more information, see [Checking object integrity][1] in the
|
2233
2267
|
# *Amazon S3 User Guide*.
|
2234
2268
|
#
|
@@ -2497,7 +2531,7 @@ module Aws::S3
|
|
2497
2531
|
# @option options [String] :ssekms_encryption_context
|
2498
2532
|
# Specifies the Amazon Web Services KMS Encryption Context as an
|
2499
2533
|
# additional encryption context to use for object encryption. The value
|
2500
|
-
# of this header is a Base64
|
2534
|
+
# of this header is a Base64 encoded string of a UTF-8 encoded JSON,
|
2501
2535
|
# which contains the encryption context as key-value pairs. This value
|
2502
2536
|
# is stored as object metadata and automatically gets passed on to
|
2503
2537
|
# Amazon Web Services KMS for future `GetObject` operations on this
|
@@ -2692,7 +2726,7 @@ module Aws::S3
|
|
2692
2726
|
# },
|
2693
2727
|
# },
|
2694
2728
|
# request_payer: "requester", # accepts requester
|
2695
|
-
# checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256
|
2729
|
+
# checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256, CRC64NVME
|
2696
2730
|
# expected_bucket_owner: "AccountId",
|
2697
2731
|
# })
|
2698
2732
|
# @param [Hash] options ({})
|
@@ -2869,7 +2903,7 @@ module Aws::S3
|
|
2869
2903
|
# request_payer: "requester", # accepts requester
|
2870
2904
|
# bypass_governance_retention: false,
|
2871
2905
|
# expected_bucket_owner: "AccountId",
|
2872
|
-
# checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256
|
2906
|
+
# checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256, CRC64NVME
|
2873
2907
|
# })
|
2874
2908
|
# @param options ({})
|
2875
2909
|
# @option options [String] :mfa
|
@@ -2933,22 +2967,23 @@ module Aws::S3
|
|
2933
2967
|
# For the `x-amz-checksum-algorithm ` header, replace ` algorithm ` with
|
2934
2968
|
# the supported algorithm from the following list:
|
2935
2969
|
#
|
2936
|
-
# * `
|
2970
|
+
# * `CRC-32`
|
2971
|
+
#
|
2972
|
+
# * `CRC-32C`
|
2937
2973
|
#
|
2938
|
-
# * `
|
2974
|
+
# * `CRC-64NVME`
|
2939
2975
|
#
|
2940
|
-
# * `
|
2976
|
+
# * `SHA-1`
|
2941
2977
|
#
|
2942
|
-
# * `
|
2978
|
+
# * `SHA-256`
|
2943
2979
|
#
|
2944
2980
|
# For more information, see [Checking object integrity][1] in the
|
2945
2981
|
# *Amazon S3 User Guide*.
|
2946
2982
|
#
|
2947
2983
|
# If the individual checksum value you provide through
|
2948
2984
|
# `x-amz-checksum-algorithm ` doesn't match the checksum algorithm you
|
2949
|
-
# set through `x-amz-sdk-checksum-algorithm`, Amazon S3
|
2950
|
-
#
|
2951
|
-
# that matches the provided value in `x-amz-checksum-algorithm `.
|
2985
|
+
# set through `x-amz-sdk-checksum-algorithm`, Amazon S3 fails the
|
2986
|
+
# request with a `BadDigest` error.
|
2952
2987
|
#
|
2953
2988
|
# If you provide an individual checksum, Amazon S3 ignores any provided
|
2954
2989
|
# `ChecksumAlgorithm` parameter.
|
@@ -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
|
@@ -848,7 +860,7 @@ module Aws::S3
|
|
848
860
|
# request_payer: "requester", # accepts requester
|
849
861
|
# bypass_governance_retention: false,
|
850
862
|
# expected_bucket_owner: "AccountId",
|
851
|
-
# checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256
|
863
|
+
# checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256, CRC64NVME
|
852
864
|
# })
|
853
865
|
# @param options ({})
|
854
866
|
# @option options [String] :mfa
|
@@ -912,22 +924,23 @@ module Aws::S3
|
|
912
924
|
# For the `x-amz-checksum-algorithm ` header, replace ` algorithm ` with
|
913
925
|
# the supported algorithm from the following list:
|
914
926
|
#
|
915
|
-
# * `
|
927
|
+
# * `CRC-32`
|
928
|
+
#
|
929
|
+
# * `CRC-32C`
|
916
930
|
#
|
917
|
-
# * `
|
931
|
+
# * `CRC-64NVME`
|
918
932
|
#
|
919
|
-
# * `
|
933
|
+
# * `SHA-1`
|
920
934
|
#
|
921
|
-
# * `
|
935
|
+
# * `SHA-256`
|
922
936
|
#
|
923
937
|
# For more information, see [Checking object integrity][1] in the
|
924
938
|
# *Amazon S3 User Guide*.
|
925
939
|
#
|
926
940
|
# If the individual checksum value you provide through
|
927
941
|
# `x-amz-checksum-algorithm ` doesn't match the checksum algorithm you
|
928
|
-
# set through `x-amz-sdk-checksum-algorithm`, Amazon S3
|
929
|
-
#
|
930
|
-
# that matches the provided value in `x-amz-checksum-algorithm `.
|
942
|
+
# set through `x-amz-sdk-checksum-algorithm`, Amazon S3 fails the
|
943
|
+
# request with a `BadDigest` error.
|
931
944
|
#
|
932
945
|
# If you provide an individual checksum, Amazon S3 ignores any provided
|
933
946
|
# `ChecksumAlgorithm` parameter.
|
@@ -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
|
@@ -29,24 +29,17 @@ for different buckets.
|
|
29
29
|
# @api private
|
30
30
|
class Handler < Seahorse::Client::Handler
|
31
31
|
def call(context)
|
32
|
-
if (
|
33
|
-
# S3 Express endpoint - turn off md5 and enable crc32 default
|
34
|
-
if props['backend'] == 'S3Express'
|
35
|
-
if context.operation_name == :put_object || checksum_required?(context)
|
36
|
-
context[:default_request_checksum_algorithm] = 'CRC32'
|
37
|
-
end
|
38
|
-
context[:s3_express_endpoint] = true
|
39
|
-
end
|
32
|
+
context[:s3_express_endpoint] = true if s3_express_endpoint?(context)
|
40
33
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
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
|
49
41
|
end
|
42
|
+
|
50
43
|
with_metric(credentials) { @handler.call(context) }
|
51
44
|
end
|
52
45
|
|
@@ -58,10 +51,8 @@ for different buckets.
|
|
58
51
|
Aws::Plugins::UserAgent.metric('S3_EXPRESS_BUCKET', &block)
|
59
52
|
end
|
60
53
|
|
61
|
-
def
|
62
|
-
context
|
63
|
-
(context.operation.http_checksum &&
|
64
|
-
context.operation.http_checksum['requestChecksumRequired'])
|
54
|
+
def s3_express_endpoint?(context)
|
55
|
+
context[:endpoint_properties]['backend'] == 'S3Express'
|
65
56
|
end
|
66
57
|
end
|
67
58
|
|
@@ -6,81 +6,20 @@ module Aws
|
|
6
6
|
module S3
|
7
7
|
module Plugins
|
8
8
|
# @api private
|
9
|
-
# This plugin is
|
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
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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
|
data/lib/aws-sdk-s3/presigner.rb
CHANGED
@@ -193,15 +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)
|
203
201
|
req.handlers.remove(Aws::Plugins::InvocationId::Handler)
|
204
|
-
|
202
|
+
req.handlers.remove(Aws::Plugins::Sign::Handler)
|
203
|
+
req.handlers.remove(Aws::S3::Plugins::S3Signer::LegacyHandler)
|
205
204
|
req.handle(step: :send) do |context|
|
206
205
|
# if an endpoint was not provided, force secure or insecure
|
207
206
|
if context.config.regional_endpoint
|