我已经实现了以下异步 blob 上传方法来上传多个块。
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);
它会引发异常“其中一个 HTTP 标头的值格式不正确”。
需要您的投入
问候, 维维克