简体   繁体   中英

Spring Integration get FTP files recursively with outbound-gateway

I'm trying to get all files within a directory structure of 3 levels deep.
For example:
- the image a.jpg exists in a folder /images/12/34/
- the image b.jpg exists in a folder /images/56/78

I've tried the outbound-gateway like stated in :

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

My configuration :

<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"/>

I've omitted the splitter and just print everything out for testing purposes.

When testing, I do not get any file. I've tried setting the folder to /images/* and then it returns all images under the 'images' folder but not recursively as stated in the links provided. So folders /12/34 and /56/78 aren't taken into account.

I cannot see what I'm missing. Can anyone help?

PS I'm working on Spring Integration 2.2.6 without the option to upgrade to 4.0.2 (newest), because I'm using a framework. Otherwise I'd use the -R option for the gateway!

I just tested with foo/foo/bar/qux.txt and foo/foo/baz/fiz.txt with

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

and it worked fine; as expected...

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

(I added the -1 option to just get the filename).

This was using linux ftpd on the server side.

Are you sure the files are in /images and not images ? (Or is the user chrooted so / is his home)?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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