@@ -125,7 +125,10 @@ def put_object(
125
125
key_object .checksum_algorithm = checksum_algorithm
126
126
127
127
headers = context .request .headers
128
- if "aws-chunked" in (headers .get ("Content-Encoding" ) or "" ).lower ():
128
+ # AWS specifies that the `Content-Encoding` should be `aws-chunked`, but some SDK don't set it.
129
+ # Rely on the `x-amz-content-sha256` which is a more reliable indicator that the request is streamed
130
+ content_sha_256 = (headers .get ("x-amz-content-sha256" ) or "" ).upper ()
131
+ if content_sha_256 and content_sha_256 .startswith ("STREAMING-" ):
129
132
# this is a chunked request, we need to properly decode it while setting the key value
130
133
decoded_content_length = int (headers .get ("x-amz-decoded-content-length" , 0 ))
131
134
key_object .set_value_from_chunked_payload (body , decoded_content_length )
@@ -278,7 +281,10 @@ def upload_part(self, context: RequestContext, request: UploadPartRequest) -> Up
278
281
body = request .get ("Body" ) or BytesIO ()
279
282
decoded_content_length = None
280
283
headers = context .request .headers
281
- if "aws-chunked" in (headers .get ("Content-Encoding" ) or "" ).lower ():
284
+ # AWS specifies that the `Content-Encoding` should be `aws-chunked`, but some SDK don't set it.
285
+ # Rely on the `x-amz-content-sha256` which is a more reliable indicator that the request is streamed
286
+ content_sha_256 = (headers .get ("x-amz-content-sha256" ) or "" ).upper ()
287
+ if content_sha_256 and content_sha_256 .startswith ("STREAMING-" ):
282
288
# this is a chunked request, we need to properly decode it while setting the key value
283
289
decoded_content_length = int (headers .get ("x-amz-decoded-content-length" , 0 ))
284
290
0 commit comments