简体   繁体   中英

How to generate dynamic local dir for incoming file depending upon file name in spring integration for SFTP adaptor

I have following configuration in my sftp inbound adaptor

  <int-sftp:inbound-channel-adapter id="sftpInbondAdapter"
                                      channel="sftpInboundChannel"
                                      session-factory="sftpSessionFactory"
                                      filename-pattern="*.DONE"
                                      remote-directory="/C:/Users/Desktop"                                       
                                      local-directory="D:\Documents1"
                                      auto-create-local-directory="false"
                                      local-filename-generator-expression="#this"
                                      delete-remote-files="false" >
        <int:poller fixed-rate="1000" task-executor="executor"/>
    </int-sftp:inbound-channel-adapter>

I want to generate dynamic local directory for incoming file depending upon file name. Like test123.Done is the file name then i have to put that file in my local dir D:\\Documents1\\test123\\test123.Done likewise. So how to generate dynamic path for local-directory="" in my sftp in inbound adaptor ???

You cannot use the inbound adapter for that.

You can use outbound gateways to do that; use one to get a list ( ls ) of the remote directory and a second one to fetch ( get ) each file - it takes a local directory expression and a local filename generator expression.

The SFTP sample uses gateways to list, get, and remove remote files .

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