2017-12-15 8 views
1

나는 Azure blob storage에서 비디오를 다운로드하려고합니다. 하지만 다운로드 할 때마다 파일은 항상 비어 있습니다. 같은 파일을 저장소에 업로드하고 확인하여 테스트 해 보았습니다. blob 파일의 크기를 확인할 때 Azure 저장소에 비어 있습니다.Azure Blob Storage에서 비디오를 다운로드하는 방법은 무엇입니까?

 //Gets the folder and the particular video to upload to YouTube 
     CloudBlobContainer videoscontainer = blobClient.GetContainerReference("videos"); 
     CloudBlob videofile = videoscontainer.GetBlobReference("test.mp4"); 

     MemoryStream videofileinmemory = new MemoryStream(); 
     await videofile.DownloadToStreamAsync(videofileinmemory); 


     CloudBlobContainer container = blobClient.GetContainerReference("checkedvideos"); 
     //Create the container if it doesn't already exist. 
     container.CreateIfNotExists(); 
     container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob }); 

     CloudBlockBlob blockBlob = container.GetBlockBlobReference("sametestfile.mp4"); 
     blockBlob.UploadFromStream(videofileinmemory); 
+0

'videofileinmemory' 스트림의 크기는 얼마입니까? –

+0

* blob *이 비어 있으면 다운로드 할 비디오가 없습니다. * 업로드 * 작업이 확실합니까? –

+0

@GauravMantri 비디오의 크기는 8MB입니다. –

답변

0

하늘빛 블롭 저장 장치에는 파일 유형이 없습니다. 따라서 다른 BLOB에서 .mp4 BLOB를 다운로드해도 차이는 없습니다.

blob을 업로드하기 전에 비디오 파일을 메모리 위치 = 0으로 재설정해야합니다. 그렇다면 그것이 작동합니다.

videofileinmemory.Position = 0; 
blockBlob.UploadFromStream(videofileinmemory); 

우리가 다른 하나 개의 컨테이너에서 덩어리를 복사하려면

는 메모리에 방울을 다운로드 할 필요 없다. CloudBlockBlob.StartCopy을 사용할 수도 있습니다.

CloudBlockBlob videofile = videoscontainer.GetBlockBlobReference("test.mp4"); 
CloudBlockBlob blockBlob = container.GetBlockBlobReference("sametestfile.mp4"); 
blockBlob.StartCopy(videofile); 
관련 문제