gpt4 book ai didi

java - Spring Integration 使用出站网关递归获取 FTP 文件

转载 作者:行者123 更新时间:2023-11-29 08:48:17 25 4
gpt4 key购买 nike

我正在尝试获取 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
and
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/* 然后它返回“图像”文件夹下的所有图像,但不是如提供的链接中所述递归。因此不考虑文件夹/12/34 和/56/78。

我看不到我错过了什么。谁能帮忙?

附言我正在使用 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 中吗? (或者用户是否已 chroot,所以 / 是他的家)?

关于java - Spring Integration 使用出站网关递归获取 FTP 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23994944/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com