PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 1, 2022

[FIXED] How do I get a list of files after an mput operation in ftp outbound gateway?

 August 01, 2022     ftp, spring, spring-integration, spring-integration-dsl     No comments   

Issue

I manage to transfer file from local to remote ftp. Now, I want the list of paths and files that was involved so that I may apply logic on it like inserting new rows into the database. It was said that

The message payload resulting from an mput operation is a List object (that is, a List of remote file paths resulting from the transfer).

which I get from here

Here is my code, in which credited to Gary Russell for providing answer from my previous question

@Bean(value = "localToFtp")
public IntegrationFlow fileToFile() {
    IntegrationFlow flow = IntegrationFlows
            .fromSupplier(() -> "/local",
                    e -> e.poller(Pollers.fixedDelay(Duration.ofSeconds(5))))
            .handle(Sftp.outboundGateway(awasDelegatingSessionFactory(),
                    AbstractRemoteFileOutboundGateway.Command.MPUT,
                    null)
                    .autoCreateDirectory(true)
                    .options(AbstractRemoteFileOutboundGateway.Option.RECURSIVE)
                    .remoteDirectoryExpression(REMOTE_DIR))
            .channel("nullChannel")
            .get();
    return flow;
}

Thanks in advance.


Solution

You are discarding the list of file names returned by the gateway, by sending it to nullChannel.

Add another .handle() method there - the message payload is the list of remote paths.



Answered By - Gary Russell
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing