현재 BLOB 내용을 텍스트 문자열로 다운로드하려면 DownloadToStream 메서드를 사용하여 Azure blob 저장소에서 파일을 다운로드하려고합니다. 그러나 나는 아무것도 돌려받지 못하고 있지만 빈 문자열이 있습니다.하늘색 방울 저장소 다운로드 스트림으로 돌아 가기 ""asp.net
하늘빛 얼룩 컨테이너에 연결하고 얼룩 파일을 검색하는 데 사용하는 코드입니다.
public static string DownLoadFroalaImageAsString(string blobStorageName, string companyID)
{
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference(companyID.ToLower());
//retrieving the actual filename of the blob
string removeString = "BLOB/";
string trimmedString = blobStorageName.Remove(blobStorageName.IndexOf(removeString), removeString.Length);
// Retrieve reference to a blob named "trimmedString"
CloudBlockBlob blockBlob2 = container.GetBlockBlobReference(trimmedString);
string text;
using (var memoryStream = new MemoryStream())
{
blockBlob2.DownloadToStream(memoryStream);
text = System.Text.Encoding.UTF8.GetString(memoryStream.ToArray());
}
return text;
}
나는 this 문서를 따라 갔지만 작동하지는 않습니다. 어떤 도움이라도 대단히 감사하겠습니다.
고마워요! blob 저장소 컨테이너에 파일을 업로드하는 방법에 문제가있어서 파일이 존재하지 않아서 내 코드가 아무 것도 반환하지 않는 이유는 무엇입니까? : -S –
@HaydenPassmore 최대 업로드 문제는 다음과 같습니다. 소스 스트림 (재) 위치가 0으로 설정되어 있습니까? 꽤 많은 시간을 내게주었습니다. –
@RickvandenBosch 스트림 위치 감사에 문제가있었습니다. 나는 오늘 일찍 질문을 올렸다. [https://stackoverflow.com/questions/46418526/uploading-file-to-azure-blob-storage-then-sending-http-response-with-the-files-b] –