azureファイルストレージからPDFファイルをダウンロードするにはどうすればよいですか?私は方法があることを知っていますdownloadText()
しかしそれはpdfファイルを壊します。私は紺碧の上にアップロードされたファイルをダウンロードするコードを書いて、私はdownloadText()
メソッドを使用しましたが、ここでは機能しません。azure用java apiを使用してPDFファイルをダウンロードできません
ただし、pdfファイルをダウンロードしますが、ファイルが破損しているか破損しています。私がやろうとしています
コードサンプル:
CloudFileDirectory sampleDir = rootDir.getDirectoryReference(path);
//Get a reference to the file you want to download
CloudFile file = sampleDir.getFileReference(fileStorageBean.getUniqueFileIdentifier());
//get file contents from azure file.
String fileContent = file.downloadText();
ESAPI.httpUtilities().setHeader(response, "Content-Disposition","attachment;");
response.setContentType(fileStorageBean.getMimeType());
response.setContentLength(file.getStreamWriteSizeInBytes());
InputStream in = new ByteArrayInputStream(fileContent.getBytes());
テキストファイルとしてダウンロードする代わりに、バイト配列に直接ダウンロードするか、ストリームにダウンロードしてみてください。 http://azure.github.io/azure-storage-java/com/microsoft/azure/storage/file/CloudFile.html#downloadToByteArray(byte []、int)。 HTH。 –
ありがとうGaurav ...はい、問題がどこにあったのですか... downloadText()。 –