繁体   English   中英

Spring Integration通过出站网关递归获取FTP文件

[英]Spring Integration get FTP files recursively with outbound-gateway

我正在尝试深入3级目录结构中的所有文件。
例如:
-图片a.jpg存在于/ images / 12/34 /文件夹中
-图像b.jpg存在于/ images / 56/78文件夹中

我已经尝试了出站网关,如中所述:

https://github.com/spring-projects/spring-integration-samples/blob/master/basic/ftp/src/test/resources/META-INF/spring/integration/FtpOutboundGatewaySample-context.xml

http://forum.spring.io/forum/spring-projects/integration/104612-inbound-ftp-polling-sub-directories?p=604430#post604430

我的配置:

<bean id="ftpSessionFactory"
    class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
    <property name="host" value="127.0.0.1"/>
    <property name="port" value="21"/>
    <property name="username" value="Administrator"/>
    <property name="password" value="SgtSpeedy1"/>
    <property name="fileType" value="2"/>
    <property name="clientMode" value="2" />
</bean>

<int-ftp:outbound-gateway id="gatewayLS"
    cache-sessions="false"
    session-factory="ftpSessionFactory"
    request-channel="inbound"
    command="ls"
    command-options=""
    expression="'/images/*/*'"
    reply-channel="toSplitter"/>

<int:channel id="toSplitter" />
<int-stream:stdout-channel-adapter channel="toSplitter" append-newline="true"/>

我省略了分离器,仅打印了所有内容以进行测试。

测试时,我没有任何文件。 我尝试将文件夹设置为/ images / *,然后返回“ images”文件夹下的所有图像,但不按提供的链接所述递归返回。 因此不考虑文件夹/ 12/34和/ 56/78。

我看不到我想念的东西。 有人可以帮忙吗?

PS我正在使用Spring Integration 2.2.6,但没有选择升级到4.0.2(最新)的选项,因为我使用的是框架。 否则,我将-R选项用于网关!

我刚刚使用foo/foo/bar/qux.txtfoo/foo/baz/fiz.txt进行了测试

<int-ftp:outbound-gateway id="gatewayLS"
    session-factory="ftpSessionFactory"
    request-channel="inbound"
    command="ls"
    command-options="-1"
    expression="'foo/*/*'"
    reply-channel="toSplitter"/>

而且效果很好; 如预期...

11:34:55.983 DEBUG [main] ...[Payload ArrayList content=[fiz.txt, qux.txt]]...

(我添加了-1选项以仅获取文件名)。

这是在服务器端使用linux ftpd。

您确定文件位于/images而不是images吗? (或者用户是这样, /他的家是这样)?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM