Skip to content

Commit 5b92634

Browse files
Do not set Content-MD5 in S3. (#5226)
[SC-52300](https://app.shortcut.com/tiledb-inc/story/52300/do-not-set-content-md5-in-s3) This PR removes setting the `Content-MD5` header on S3 uploads. There are multiple reasons for this: * The header is [not supported on directory buckets](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-express-differences.html#s3-express-differences-unsupported-features) used by S3 Express One Zone. * Computing the MD5 hash of the data immediately before uploading them has a performance overhead and does not provide additional security. * We don't do a similar thing in the other cloud VFSes. Validated by: * Creating, writing, consolidating and vacuuming an array on a directory bucket. * Running `quickstart_dense_cpp` on a Google Cloud Storage bucket using the S3 compatibility API. --- TYPE: BUG DESC: Fix incompatibilities with S3 Express One Zone, by stopping setting `Content-MD5` on all S3 uploads. Co-authored-by: KiterLuc <[email protected]>
1 parent ca51aa0 commit 5b92634

File tree

1 file changed

+0
-18
lines changed
  • tiledb/sm/filesystem

1 file changed

+0
-18
lines changed

tiledb/sm/filesystem/s3.cc

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,12 +1786,6 @@ void S3::write_direct(const URI& uri, const void* buffer, uint64_t length) {
17861786
put_object_request.SetBody(stream);
17871787
put_object_request.SetContentLength(length);
17881788

1789-
// we only want to hash once, and must do it after setting the body
1790-
auto md5_hash =
1791-
Aws::Utils::HashingUtils::CalculateMD5(*put_object_request.GetBody());
1792-
1793-
put_object_request.SetContentMD5(
1794-
Aws::Utils::HashingUtils::Base64Encode(md5_hash));
17951789
put_object_request.SetContentType("application/octet-stream");
17961790
put_object_request.SetBucket(aws_uri.GetAuthority());
17971791
put_object_request.SetKey(aws_uri.GetPath());
@@ -1815,16 +1809,6 @@ void S3::write_direct(const URI& uri, const void* buffer, uint64_t length) {
18151809
outcome_error_message(put_object_outcome));
18161810
}
18171811

1818-
// verify the MD5 hash of the result
1819-
// note the etag is hex-encoded not base64
1820-
Aws::StringStream md5_hex;
1821-
md5_hex << "\"" << Aws::Utils::HashingUtils::HexEncode(md5_hash) << "\"";
1822-
if (md5_hex.str() != put_object_outcome.GetResult().GetETag()) {
1823-
throw S3Exception(
1824-
"Object uploaded successfully, but MD5 hash does "
1825-
"not match result from server!' ");
1826-
}
1827-
18281812
throw_if_not_ok(wait_for_object_to_propagate(
18291813
put_object_request.GetBucket(), put_object_request.GetKey()));
18301814
}
@@ -1974,8 +1958,6 @@ S3::MakeUploadPartCtx S3::make_upload_part_req(
19741958
upload_part_request.SetPartNumber(upload_part_num);
19751959
upload_part_request.SetUploadId(upload_id);
19761960
upload_part_request.SetBody(stream);
1977-
upload_part_request.SetContentMD5(Aws::Utils::HashingUtils::Base64Encode(
1978-
Aws::Utils::HashingUtils::CalculateMD5(*stream)));
19791961
upload_part_request.SetContentLength(length);
19801962
if (request_payer_ != Aws::S3::Model::RequestPayer::NOT_SET)
19811963
upload_part_request.SetRequestPayer(request_payer_);

0 commit comments

Comments
 (0)