@@ -1000,6 +1000,18 @@ namespace Aws
10001000 handle->SetContentType (headObjectOutcome.GetResult ().GetContentType ());
10011001 handle->SetMetadata (headObjectOutcome.GetResult ().GetMetadata ());
10021002 handle->SetEtag (headObjectOutcome.GetResult ().GetETag ());
1003+ if (headObjectOutcome.GetResult ().GetChecksumType () == Aws::S3::Model::ChecksumType::FULL_OBJECT) {
1004+ if (!headObjectOutcome.GetResult ().GetChecksumCRC32C ().empty ()) {
1005+ handle->SetChecksum (headObjectOutcome.GetResult ().GetChecksumCRC32C ());
1006+ handle->SetChecksumAlgorithm (S3::Model::ChecksumAlgorithm::CRC32C);
1007+ } else if (!headObjectOutcome.GetResult ().GetChecksumCRC32 ().empty ()) {
1008+ handle->SetChecksum (headObjectOutcome.GetResult ().GetChecksumCRC32 ());
1009+ handle->SetChecksumAlgorithm (S3::Model::ChecksumAlgorithm::CRC32);
1010+ } else if (!headObjectOutcome.GetResult ().GetChecksumCRC64NVME ().empty ()) {
1011+ handle->SetChecksum (headObjectOutcome.GetResult ().GetChecksumCRC64NVME ());
1012+ handle->SetChecksumAlgorithm (S3::Model::ChecksumAlgorithm::CRC64NVME);
1013+ }
1014+ }
10031015 /* When bucket versioning is suspended, head object will return "null" for unversioned object.
10041016 * Send following GetObject with "null" as versionId will result in 403 access denied error if your IAM role or policy
10051017 * doesn't have GetObjectVersion permission.
@@ -1147,6 +1159,12 @@ namespace Aws
11471159 handle->UpdateStatus (DetermineIfFailedOrCanceled (*handle));
11481160 TriggerTransferStatusUpdatedCallback (handle);
11491161 }
1162+ // TODO: combine and check checksums
1163+ for (const auto & part : handle->GetCompletedParts ()) {
1164+ // std::map with int index SHOULD BE ordered
1165+ part.second ->GetChecksum ();
1166+ // TODO: combine all checksums from all the parts right here
1167+ }
11501168 }
11511169
11521170 void TransferManager::HandleGetObjectResponse (const Aws::S3::S3Client* client,
@@ -1204,7 +1222,20 @@ namespace Aws
12041222
12051223 Aws::String errMsg{handle->WritePartToDownloadStream (bufferStream, partState->GetRangeBegin ())};
12061224 if (errMsg.empty ()) {
1207- handle->ChangePartToCompleted (partState, outcome.GetResult ().GetETag ());
1225+ partState->SetChecksum ([&]() -> Aws::String {
1226+ if (m_transferConfig.checksumAlgorithm == S3::Model::ChecksumAlgorithm::CRC32) {
1227+ return outcome.GetResult ().GetChecksumCRC32 ();
1228+ }
1229+ if (m_transferConfig.checksumAlgorithm == S3::Model::ChecksumAlgorithm::CRC32C) {
1230+ return outcome.GetResult ().GetChecksumCRC32C ();
1231+ }
1232+ if (m_transferConfig.checksumAlgorithm == S3::Model::ChecksumAlgorithm::CRC64NVME) {
1233+ return outcome.GetResult ().GetChecksumCRC64NVME ();
1234+ }
1235+ // Return empty checksum for not set.
1236+ return " " ;
1237+ }());
1238+ handle->ChangePartToCompleted (partState, outcome.GetResult ().GetETag ());
12081239 } else {
12091240 Aws::Client::AWSError<Aws::S3::S3Errors> error (Aws::S3::S3Errors::INTERNAL_FAILURE,
12101241 " InternalFailure" , errMsg, false );
0 commit comments