亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何修復使用 Apache Commons VFS 將文件上傳到 SFTP 服務器時發生的錯誤

如何修復使用 Apache Commons VFS 將文件上傳到 SFTP 服務器時發生的錯誤

揚帆大魚 2023-12-13 16:37:21
問題我正在嘗試使用 Apache Commons VFS 從遠程桌面將文件上傳到 SFTP 服務器。連接已正確建立,但是當我將文件復制到服務器時拋出異常:代碼我編寫了負責根據此答案中的代碼將文件上傳到 SFTP 服務器的代碼。這是我的代碼:有很多日志,因為我不知道如何在遠程桌面上調試此代碼,所以我使用日志來代替它。當我從其他源接收文件并且我需要立即將此文件發送到 SFTP 服務器時,會調用此函數(這就是我使用字節數組作為輸入參數的原因)。氣缸ID應該是文件名 private int uploadFileToSFTPServer(String cylinderId, byte[] documentContent, URI locationURI) {    StandardFileSystemManager manager = new StandardFileSystemManager();    try {      manager.addProvider("sftp", new DefaultLocalFileProvider());      final String hostName = locationURI.toString();      final String remoteFilePath = "IASD/EXR3_U5/" + cylinderId + ".txt";      LogHandler.log(LOGGER_NAME, LogLevel.DEBUG, "Remote Path: " + remoteFilePath);      InputStream inStream = new ByteArrayInputStream(documentContent);      String localPath = "E:\\SavedDocument\\TemporarySavedDocs\\" + cylinderId + ".txt";      try {        LogHandler.log(LOGGER_NAME, LogLevel.DEBUG, "Local path:" + localPath);        Files.copy(inStream, Paths.get(localPath));      } catch (Exception e) {        LogHandler.log(LOGGER_NAME, LogLevel.WARN, "Exception while creating the file on local:" + e.getMessage());      }      final String loginFTP = lindeCustomServiceConfig.getValueForConfigKey(          LindeCustomServiceConfigurationKeys.csLoginFTP, "admin");      final String passwordFTP = lindeCustomServiceConfig.getValueForConfigKey(          LindeCustomServiceConfigurationKeys.csPasswordFTP, "admin");      LogHandler.log(LOGGER_NAME, LogLevel.DEBUG, "FTP user login:" + loginFTP);      LogHandler.log(LOGGER_NAME, LogLevel.DEBUG, "FTP user password: " + passwordFTP);      manager.init();    } 對于如何修復此錯誤的建議,我將不勝感激。
查看完整描述

1 回答

?
暮色呼如

TA貢獻1853條經驗 獲得超9個贊

我對 VFS 沒什么經驗,但這看起來很可疑:

manager.addProvider("sftp", new DefaultLocalFileProvider());

我想應該是:

manager.addProvider("sftp", new SftpFileProvider());


查看完整回答
反對 回復 2023-12-13
  • 1 回答
  • 0 關注
  • 187 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號