1

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

2
  • 1
    Can you check the fiddler trace to identify for which Put Block request you're getting an error. That should tell you the headers sent with each request as well. Commented Sep 24, 2012 at 14:48
  • @Vivek - I see that you just un-accepted my answer. What did the problem turn out to be? Commented Sep 27, 2012 at 14:23

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

2

In my case "The value for one of the HTTP headers is not in the correct format" error occurred because I was trying to write an empty block (memoryStream had 0 bytes). PutBlock failed beause the content length was 0 in the header.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.