Here is my sample code:
auto cClient = client.GetBlobContainerClient(cName);
auto bClient = cClient.GetBlockBlobClient(bName);
auto res = bClient.UploadFrom(reinterpret_cast<const std::uint8_t *>(buffer), bufferSize);
Azure::Core::Cryptography::Md5Hash md5Hash;
md5Hash.Append(reinterpret_cast<const std::uint8_t *>(buffer), bufferSize);
if(md5Hash.Final() != res.Value.TransactionalContentHash.Value().Value){
std::cout << "Not equal " << std::endl;
}else{
std::cout << "Equal " << std::endl;
}
I want to verify md5 hash of uploaded file. I've read the documentation and it's little confusing. It says that you can calculate md5 of file locally and somehow set it to the request and Azure on the server side will calculate md5 on it's own and compare it to the one you provided and will fail if they don't match.
I've also read that you receive md5 as a response from Azure and you can compare it locally. I have 2 questions here:
- With the code above I'm trying calculate hash of file locally and compare it to the one provided by Azure, but for some reason they are always not equal, Am I missing something?
- How can I provide md5 of a file to the upload function so that Azure fails to upload if they don't match?
Thanks