Question

Using Delphi XE2 Update 3 I'm having a problem uploading a block of zero bytes to Azure. When I say zero bytes, I mean an array of bytes with each element set to zero (it's not zero length).

For example:

var
  ConInfo: TAzureConnectionInfo;
  RespInfo: TCloudResponseInfo;
  BlobService: TAzureBlobService;
  Content: TBytes;
  MD5: String;
  Hasher: TIdHashMessageDigest5;
begin
  ConInfo:=TAzureConnectionInfo.Create(self);
  ConInfo.AccountName:='YOUR ACCOUNT NAME';
  ConInfo.AccountKey:='YOUR ACCOUNT KEY';
  ConInfo.Protocol:='http';

  BlobService:=TAzureBlobService.Create(ConInfo);    
  RespInfo:=TCloudResponseInfo.Create;

  SetLength(Content, 1048576); // 1 MByte
  FillMemory(@Content[0], 1048576, 0); // << --- fill it with anything except 0 and it works

  Hasher:=TIdHashMessageDigest5.Create;
  MD5:=Data.Cloud.CloudAPI.EncodeBytes64(Hasher.HashBytes(Content));
  Hasher.Free;

  BlobService.PutBlock('CONTAINER NAME', 'BLOB NAME', MD5, Content, MD5, '', RespInfo);

If the above code is run then an exception is raised on the call to PutBlock:

Project Project1.exe raised exception class EIPHTTPProtocolExceptionPeer with message 'HTTP/1.1 403 Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.'.

But if you change the FillMemory line so that it fills it with 1's (or anything but zero), then it works without error. Why?

Thanks for any help.

Was it helpful?

Solution

Unbelievably, it seems that the problem is the block ID value of ttgbNgpWctgMJ0MPORU+LA==

If you use it as a block ID then you get that error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top