Azure Storage blob을 ashx에 전달하려고합니다. Microsoft.WindowsAzure.Storage.StorageException: Calculated MD5 does not match existing property
Azure Storage 계산 된 MD5가 기존 속성과 일치하지 않습니다.
내가 올바른 덩어리를 찾는 것을 알고 다음 blockBlob.DownloadToStream (MemoryStream을)에 다음과 같은 예외를 던지고. 존재하지 않는 컨테이너와 경로를 넣으면 대신 404 예외가 발생합니다.
나는이 오류의 원인이 무엇인지 힌트를 봤지만 아무 도움이되지 않습니다. 이 문제의 원인에 대해 생각을 가진 사람이 있습니까? 지난 몇 일 동안이 코드를 몇 가지 방법으로 다시 작성했지만 항상 DownloadToStream에서 종료됩니다.
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
public void ProcessRequest(HttpContext context) {
// Retrieve storage account from connection string.
Microsoft.WindowsAzure.Storage.CloudStorageAccount storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(Microsoft.WindowsAzure.CloudConfigurationManager.GetSetting("StorageConnectionString"));
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference("gmt");
// Retrieve reference to blob named "articles/142/222.jpg".
CloudBlockBlob blockBlob = container.GetBlockBlobReference("articles/142/222.jpg");
using (var memoryStream = new MemoryStream()) {
blockBlob.DownloadToStream(memoryStream);
byte[] photoByte = ReadFully(memoryStream);
context.Response.Clear();
context.Response.ContentType = "image/jpeg";
context.Response.OutputStream.Write(photoByte, 0, photoByte.Length);
}
}
public static byte[] ReadFully(Stream input) {
input.Position = 0;
using (MemoryStream ms = new MemoryStream()) {
input.CopyTo(ms);
return ms.ToArray();
}
}
감사합니다. 나는 오늘 밤 이걸 시험해 볼거야. 나는 Azure Blob Storage Bridge에 FTP를 사용하여 13 기가의 이미지를 업로드했습니다. 내가 시도한 모든 파일이 나 에게이 오류 메시지를 제공합니다. 이것이 모든 파일을 손상시키는 것인지 궁금합니다. –
예외가 사라졌습니다. ashx 여전히 단지 0 바이트를 반환하지만. booooooo ... –
당신의'ReadFully()'함수에서'ms'의 위치를 확인하십시오. 그것이 0에 있는지 확인하십시오. –