SetContentMD5 is no use in my program #2433
-
I tried to use real md5 and fake md5 to set into request. But both can work normally. void put_object_buf(Aws::String& bucketName, Aws::String& objectName, S3::S3Client& s3_client)
{
Aws::S3::Model::PutObjectRequest putObjectRequest;
putObjectRequest.SetBucket(bucketName);
std::shared_ptr<Aws::IOStream> bigStream = Create5MbStreamForUploadPart("La");
putObjectRequest.SetBody(bigStream);
putObjectRequest.SetContentLength(static_cast<long>(putObjectRequest.GetBody()->tellp()));
putObjectRequest.SetContentMD5(Aws::Utils::HashingUtils::Base64Encode(Aws::Utils::HashingUtils::CalculateMD5(*putObjectRequest.GetBody())));
putObjectRequest.SetContentMD5("123"); // still put success
putObjectRequest.SetKey(objectName);
Aws::S3::Model::PutObjectOutcome outcome = s3_client.PutObject(putObjectRequest);
if (!outcome.IsSuccess()) {
std::cerr << "Error: PutObjectBuffer: " <<
outcome.GetError().GetMessage() << std::endl;
}
else {
std::cout << "Success: Object '" << objectName << "' uploaded to bucket '" << bucketName << "'." << std::endl;
std::cout << "outcome crc32: " << outcome.GetResult().GetChecksumCRC32() << std::endl;
std::cout << "outcome etag: " << outcome.GetResult().GetETag() << std::endl;
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Could you please help me out? @sdavtaker |
Beta Was this translation helpful? Give feedback.
-
I think this may be caused by AddChecksumToRequest? @sdavtaker |
Beta Was this translation helpful? Give feedback.
-
I've made to PUT requests with this code:
and watched the requests via fiddler. Here's the diff of both requests
It seems the manually specified MD5 hash isn't part of the data that goes to s3. |
Beta Was this translation helpful? Give feedback.
-
@github-actions proposed-answer @lucaspeng12138 sorry for the late reply. We were recalculating the md5 previously, but we fixed that here: #2788 |
Beta Was this translation helpful? Give feedback.
@github-actions proposed-answer
@lucaspeng12138 sorry for the late reply. We were recalculating the md5 previously, but we fixed that here: #2788
Can you try updating to the latest version of this sdk and see if you run into any unexpected behaviors with SetContentMD5