I have implemented following async blob upload method to upload multiple blocks.
var container = GetContainer(containerName);
var blob = container.GetBlockBlobReference(blobName);
String[] base64EncodedBlockIds = new String[10];// 10- number of Blocks
//To upload the blocks in parallel - 10 parallel blocks
ParallelLoopResult parallelLoopResult = Parallel.For(0,10, i =>
{
String base64EncodedBlockId = Convert.ToBase64String(System.BitConverter.GetBytes(i));
byte[] bytesMemoryStream = GetBytesFromStream(stream);
using (MemoryStream memoryStream = new MemoryStream(bytesMemoryStream))
{
blob.PutBlock(base64EncodedBlockId, memoryStream, null);// throws an exception "The value for one of the HTTP headers is not in the correct format"
}
base64EncodedBlockIds[i] = base64EncodedBlockId;
});
blob.PutBlockList(base64EncodedBlockIds);
It throws an exception “The value for one of the HTTP headers is not in the correct format”.
Need your inputs
Regards,
Vivek
BlockIDs within a blob must all be the same length (number of characters). BlockID “10” is longer than the others, which is probably the source of your problem.
One solution would be to zero-pad the BlockIDs to the same length.