Why my blob is broken when I download it?

Sep 3 2020 2:18 PM
So what I am doing is uploading video chunk by chunk with PutBlock. The requester sends me the video divided by 4mb chunks by per request(if the video is 17mb requester will send 5 requests, to upload 4mb chunk). I am using PutBlock method to "append" blob... When I download this video from blob it is broken... But if the requester sends me only 3mb video it is not broken(in 3mb video I mean full video and not splitted by chunks)...
 
Please help...
  1. public async Task<CloudBlockBlob> AppendBlobOnAssetAsync(UploadRequest request)  
  2. {  
  3. using Stream stream = new MemoryStream();  
  4. request.File.CopyTo(stream);  
  5. stream.Position = 0;  
  6. var cloudBlobContainer = new CloudBlobContainer(request.InputAssetStorageUri);  
  7. var blockBlob = cloudBlobContainer.GetBlockBlobReference(request.BlobName);  
  8. var blockItems = new List<ListBlockItem>();  
  9. var blockItemIds = new List<string>();  
  10. if (request.BlockId > 0)  
  11. {  
  12. var blocks = await blockBlob.DownloadBlockListAsync();  
  13. blockItems = blocks.ToList();  
  14. blockItemIds = blockItems.Select(blockItem => blockItem.Name).ToList();  
  15. }  
  16. var blockId = Convert.ToBase64String(Encoding.UTF8.GetBytes(request.BlockId.ToString(CultureInfo.InvariantCulture).PadLeft(30, '0'))); blockBlob.PutBlock(blockId, stream, null); blockItemIds.Add(blockId); blockBlob.PutBlockList(blockItemIds); return blockBlob;  
  17. }  

Answers (1)