2017-04-24 13 views
-2

www.site.com/amazing.jpg에서 Azure Blob Storage에 파일을 업로드하는 방법은 무엇입니까? 여러 개의 파일을 URL에서 Azure Blob 저장소에 업로드하십시오. 나는 이런 식으로 찾을 수 없다. 나는 여러 가지 방법으로 불행을 시도했다. ( 도움을 주셔서 감사합니다.웹 사이트 이미지에서 Azure Blob Storage에 파일을 업로드하는 방법은 무엇입니까?

+0

GauravMantri의 답변에 대한 우려가 있으십니까? –

답변

1

실제로 이것은 매우 간단하며 Azure Storage에 작업을 요청할 수 있습니다 :).

기본적으로 수행해야 할 작업은 Copy Blob입니다. 이 작업을 통해 공개적으로 액세스 할 수있는 URL을 지정할 수 있으며 Azure Storage Service는 해당 URL의 내용을 복사하여 Azure 저장소에있는 blob을 만듭니다.

 var cred = new StorageCredentials(accountName, accountKey); 
     var account = new CloudStorageAccount(cred, true); 
     var client = account.CreateCloudBlobClient(); 
     var container = client.GetContainerReference("temp"); 
     var blob = container.GetBlockBlobReference("amazing.jpg"); 
     blob.StartCopy(new Uri("www.site.com/amazing.jpg")); 
     //Since copy is async operation, if you want to see if the blob is copied successfully, you must check the status of copy operation 
     do 
     { 
      System.Threading.Thread.Sleep(1000); 
      blob.FetchAttributes(); 
      var copyStatus = blob.CopyState.Status; 
      if (copyStatus != CopyStatus.Pending) 
      { 
       break; 
      } 
     } while (true); 
     Console.WriteLine("Copy operation finished"); 
+0

대단히 감사합니다. – Berk