0
깃털 컨테이너 &에서 파일을 다운로드 중입니다. 스트림을 저장하려면 & pdf를 읽으려고합니다.스트림에서 pdf를 읽는 중 PDF 헤더 서명을 찾을 수 없습니다.
//creating a Cloud Storage instance
CloudStorageAccount StorageAccount = CloudStorageAccount.Parse(connectionstring);
//Creating a Client to operate on blob
CloudBlobClient blobClient = StorageAccount.CreateCloudBlobClient();
// fetching the container based on name
CloudBlobContainer container = blobClient.GetContainerReference(containerName);
//Get a reference to a blob within the container.
CloudBlockBlob blob = container.GetBlockBlobReference(fileName);
var memStream = new MemoryStream();
blob.DownloadToStream(memStream);
try
{
PdfReader reader = new PdfReader(memStream);
}
catch(Exception ex)
{
}
예외 : PDF 헤더 서명을 찾을 수 없습니다.
blob.DownloadToStream(memStream);
이 다운로드 한 콘텐츠를 한 후 스트림을 바로
위치 : 코멘트를 통해 문제를 해결 한 후 분명했다으로
그래서, 당신은 확신이 * * PDF 파일입니까? 로컬 파일에 저장하고 내용을 검사 해 보았습니까? –
예, 로컬로 저장하려고했지만 작동합니다. 하지만 스트림으로 작업하지 않는 이유는 확실하지 않습니다. –
또 다른 가능한 원인은'DownloadToStream'을 호출 한 후 스트림 위치가 다운로드 된 내용 뒤에 * 위치하고'PdfReader'가 현재 위치에서 Pdf를 읽을 수 있기를 기대할 수 있다는 것입니다. 'DownloadToStream' 다음에이 코드를 추가해보십시오 :'memStream.Position = 0;' –