簡體   English   中英

使用 PDFBox 保存方法將文件上傳到 SFTP 服務器而不將文件存儲到本地系統?

[英]Upload a file to an SFTP server using PDFBox save method without storing the file to the local system?

我正在嘗試將已編輯的 PDF 保存到其位置,而無需將其下載/存儲在本地計算機上。 我正在使用 JSch SFTP 方法從 SFTP 服務器獲取輸入 PDF 文件,使用

x = new BufferedInputStream(channelSftp.get("example.pdf"));
PDDocument document = PDDocument.load(x);

在使用 PDFbox 進行一些編輯后,我嘗試使用以下方法保存它:

documents.save(new File("ftp/path/location"));

我不能,因為我知道它只適用於您的本地目錄。 我也可以看到document.save接受 OutputStream` 參數,但我不知道如何在這里使用它。

使用 stream 閱讀器進行輸入沒有任何問題。 我所需要的只是將已編輯的 PDF 保存回其位置(可能替換),而無需在我的本地系統上下載它。

使用返回OutputStreamChannelSftp.put重載

try (OutputStream out = channelSftp.put("example.pdf")) {
    documents.save(out);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM