final String sftpEndpoint = "sftp://{{sftp.write.host}}" + ":" + "{{sftp.write.port}}"
+ "{{sftp.write.folder}}"
+ "?username={{sftp.write.user}}" + "&privateKey=#sftpPrivateKey"
+ "&throwExceptionOnConnectFailed=true" + "&fileExist=Override" + "&disconnect=false";
from("direct:send.xml.to.sftp").routeId("direct.ipubr-send-xml-to-sftp")
.setBody(exchangeProperty("pbol-xmldata"))
.setHeader(Exchange.FILE_NAME, exchangeProperty("pbol-sftp-filename"))
.setProperty(CommonConstants.FEI_LOG_MESSAGE_PROP, simple("Sending ${exchangeProperty.pbol-prod-location-items.size()} products to file ${exchangeProperty.pbol-sftp-filename} to sftp."))
.marshal().zipFile()
.toD(sftpEndpoint)
.end();
这是我用来上传文件的代码,但指定的文件夹结构是 /uploads/data/files 但文件是在 /uploads/data/files/uploads/data/files 中创建的。
您的 ftp 服务器可能默认您进入 /uploads/data/files,那么除此之外您还要指定 /uploads/data/files。
您可以尝试启用 org.apache.camel.component.file.remote 的日志记录来查看发生了什么。