2014-07-21 5 views
1

다음 코드를 입력하고 출력하십시오. 다운로드 할 때마다이 파일에 대해 동일한 예외가 발생합니다.AzureBlobStorage : 계산 된 MD5가 기존 속성과 일치하지 않습니다.

md5 유효성 검사없이 다운로드하고 내용을 확인하면 파일에 아무런 문제가 없으므로 mdb 속성 값이 blob 메타 데이터에서 올바르지 않다고 의심됩니다.

처음에는 어떻게 잘못 될 수 있는지 알아 내려고합니다. 파일을 업로드 할 때이 속성을 설정하는 하늘빛 블롭 저장 장치 내부가 아닙니까?

해결책으로 DisableContentMD5Validation을 사용하지 않으려합니다.

(PS. 제가 처음부터 파일을 업로드 Couldberry 탐색기를 사용)

 static void Main(string[] args) 
    { 
     { 
      try 
      { 

       var client = account.CreateCloudBlobClient(); 
       var container = client.GetContainerReference("algorithms"); 
       var blob = container.GetBlockBlobReference("SInnovations.Algorithms/SInnovations.Algorithms.FootprintFinder.1.0.0-pre-20140430.zip"); 
       blob.FetchAttributes(); 
       Console.WriteLine(blob.Properties.ContentMD5); 

       blob.DownloadToFile("c:\\dev\\test.zip", System.IO.FileMode.Create); 

      } 
      catch (StorageException ex) 
      { 
       if (ex.Message == "Calculated MD5 does not match existing property") 
       { 
        Console.WriteLine("Calculated MD5 does not match existing property"); 
       } 

      } 
     } 
     { 


      var client = account.CreateCloudBlobClient(); 
      var container = client.GetContainerReference("algorithms"); 
      var blob = container.GetBlockBlobReference("SInnovations.Algorithms/SInnovations.Algorithms.FootprintFinder.1.0.0-pre-20140430.zip"); 
      blob.FetchAttributes(); 
      Console.WriteLine(blob.Properties.ContentMD5); 

      blob.DownloadToFile("c:\\dev\\test.zip", System.IO.FileMode.Create,null,new BlobRequestOptions() 
      { 
       DisableContentMD5Validation = true, 
      }); 
      using (var md5 = MD5.Create()) 
      { 
       using (var stream = File.OpenRead("c:\\dev\\test.zip")) 
       { 
        Console.WriteLine(md5.ComputeHash(stream)); 
       } 
      } 

     } 
    } 
} 

이 출력을

RH4EqqbthSm24KPgZ2VSGQ== 
Calculated MD5 does not match existing property 
RH4EqqbthSm24KPgZ2VSGQ== 
System.Byte[] 
Press any key to continue . . . 

나쁜 예를 보여주고, 로컬 파일 MD5가 가리키고있다 Hv가 + nQRNCPQnvy4WU9 + qaQA ==.

Conclussion 속성이 어느 시점에서 잘못 설정되어야합니다.

해결책. 다운로드하여 blob의 md5 및 업데이트 속성 값을 계산하십시오.

+0

Cloudberry Explorer가 MD5를 잘못 설정했을 수 있습니까? –

+0

일 수 있습니다. 몇 가지 흥미로운 정보로 질문을 업데이트합니다. 2sec –

+0

파일을 다운로드 할 때 왜 MD5가 헤더에 저장된 것과 일치하는지 계산할 수 있습니까? 그러나 유효성 검사를 사용하지 않을 때 MD5가 실패합니다. –

답변

0

CloudBerry 저장소 탐색기 (2.4.0.163)를 통해 업로드 된 파일에서 동일한 문제가 발생했습니다. Azure 포털과 Azure 저장소 탐색기 (http://storageexplorer.com/)를 통해 동일한 파일을 업로드했지만 동일한 문제 (콘텐츠 손상 또는 md5 불일치)가 발생하지 않았습니다.

+1

Cloudberry가 md5를 계산하지 못했다고 말하면서 데이터를 업로드하고이 헤더가 Azure에 의해 생성됩니다. – Antoine