S3: fix copy in place when requesting checksum (#6308)
This commit is contained in:
parent
ebe48e7443
commit
417561cec6
@ -1627,7 +1627,7 @@ class S3Response(BaseResponse):
|
|||||||
checksum_algorithm = request.headers.get("x-amz-checksum-algorithm")
|
checksum_algorithm = request.headers.get("x-amz-checksum-algorithm")
|
||||||
if checksum_algorithm:
|
if checksum_algorithm:
|
||||||
checksum_value = compute_checksum(
|
checksum_value = compute_checksum(
|
||||||
key_to_copy.value, algorithm=checksum_algorithm
|
new_key.value, algorithm=checksum_algorithm
|
||||||
).decode("utf-8")
|
).decode("utf-8")
|
||||||
response_headers.update(
|
response_headers.update(
|
||||||
{"Checksum": {f"Checksum{checksum_algorithm}": checksum_value}}
|
{"Checksum": {f"Checksum{checksum_algorithm}": checksum_value}}
|
||||||
|
@ -68,6 +68,18 @@ def test_copy_key_boto3_with_sha256_checksum():
|
|||||||
assert "ChecksumSHA256" in resp["Checksum"]
|
assert "ChecksumSHA256" in resp["Checksum"]
|
||||||
assert resp["Checksum"]["ChecksumSHA256"] == expected_hash
|
assert resp["Checksum"]["ChecksumSHA256"] == expected_hash
|
||||||
|
|
||||||
|
# Verify in place
|
||||||
|
copy_in_place = client.copy_object(
|
||||||
|
Bucket=bucket,
|
||||||
|
CopySource=f"{bucket}/{new_key}",
|
||||||
|
Key=new_key,
|
||||||
|
ChecksumAlgorithm="SHA256",
|
||||||
|
MetadataDirective="REPLACE",
|
||||||
|
)
|
||||||
|
|
||||||
|
assert "ChecksumSHA256" in copy_in_place["CopyObjectResult"]
|
||||||
|
assert copy_in_place["CopyObjectResult"]["ChecksumSHA256"] == expected_hash
|
||||||
|
|
||||||
|
|
||||||
@mock_s3
|
@mock_s3
|
||||||
def test_copy_key_with_version_boto3():
|
def test_copy_key_with_version_boto3():
|
||||||
|
Loading…
Reference in New Issue
Block a user