java - Spring Integration SFTP 出站网关 mget -R 问题

标签 java spring-integration

我们正在尝试使用 spring 集成 [SFTP outbound-gateway] 连接到 SFTP 服务器,以下载具有以下目录表达式 '/*/*/foo/' 的所有文件。不幸的是,我们遇到了不同的异常:

    Caused by: org.springframework.core.NestedIOException: Failed to list files; nested exception is 2: No such file
at org.springframework.integration.sftp.session.SftpSession.list(SftpSession.java:103)
at org.springframework.integration.sftp.session.SftpSession.list(SftpSession.java:50)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.listFilesInRemoteDir(AbstractRemoteFileOutboundGateway.java:582)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.ls(AbstractRemoteFileOutboundGateway.java:551)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.mGetWithRecursion(AbstractRemoteFileOutboundGateway.java:753)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.mGet(AbstractRemoteFileOutboundGateway.java:713)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway$3.doInSession(AbstractRemoteFileOutboundGateway.java:455)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway$3.doInSession(AbstractRemoteFileOutboundGateway.java:451)
at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:334)
... 33 more
    Caused by: 2: No such file
at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2833)
at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:2185)
at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:2202)
at com.jcraft.jsch.ChannelSftp.ls(ChannelSftp.java:1566)
at com.jcraft.jsch.ChannelSftp.ls(ChannelSftp.java:1527)
at org.springframework.integration.sftp.session.SftpSession.list(SftpSession.java:91)
... 41 more

我们正在使用以下内容:

<int-sftp:outbound-gateway session-factory="sftpFactory" request-channel="download"
        command="mget" command-options="-R" expression="'/*/*/foo/'" remote-file-separator="/" 
        local-directory-expression="'${local.dir}'+ #remoteDirectory" reply-channel="outputChannel"
        auto-create-local-directory="true" />

最佳答案

仅支持简单的通配符,例如 /foo/* - 表示从 /foo 递归获取 - 实际上不需要 *在这种情况下,/foo/ 将执行相同的操作。

但是,无法使用通配符更高级别的目录。

根据树的复杂程度,您也许可以使用自定义过滤器 - 在每次递归期间调用过滤器(列出每个目录,应用过滤器,然后提取文件)。

关于java - Spring Integration SFTP 出站网关 mget -R 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32332260/

相关文章:

Java 和 XSS : How to html escape a JSON string to protect against XSS?

spring-integration - 竞争消费者

java - Spring 集成 ip - 仅使用 java 代码的 udp channel

spring-integration - 如何使用文件出站适配器移动锁定的文件

java - 如何使用 Java 代码刷新文件夹?

java - ORA-29531 : no method %s in class %s call java source in oracle PLSQL

java - 具有相同字符串长度的奇怪编码输出

java - Java中计算大文件中以字符串开头的行的最快方法是什么

Spring 集成 Redis RPOPLPUSH

Spring Integration 序列化 MessageHeader 对象