I try to set a MD5 hash for the files I'm uploading to azure. I get this error:
(400, 'HTTP/1.1 400 The MD5 value specified in the request is a invalid. MD5 value must be 128 bits and base64 encoded.', $7230400)
This is how I do the md5 for the file:
function MD5(const fileName : string) : string;
var
idmd5 : TIdHashMessageDigest5;
fs : TFileStream;
begin
idmd5 := TIdHashMessageDigest5.Create;
fs := TFileStream.Create(fileName, fmOpenRead OR fmShareDenyWrite) ;
try
result := idmd5.HashStreamAsHex(fs) ;
finally
fs.Free;
idmd5.Free;
end;
end;
......
Headers.Values['Content-MD5'] := MD5(LocalFile);
Now, how do this according to azure specs on delphi xe2?
PD: This answer How to resolve an InvalidMd5 error returned from the Windows Azure Blob Storage service? solve it for .NET:
MD5 md5 = new MD5CryptoServiceProvider();
byte[] blockHash = md5.ComputeHash(buff);
string convertedHash = Convert.ToBase64String(blockHash, 0, 16);
But don't know how traslate to delphi..