如何在 ftp 出站网关中进行 mput 操作后获取文件列表?
我设法将文件从本地 ftp 传输到远程 ftp。现在,我想要所涉及的路径和文件的列表,以便我可以对其应用逻辑,例如将新行插入数据库。据说
mput 操作产生的消息有效负载是一个 List 对象(即传输产生的远程文件路径列表)。
我从这里
这是我的代码,其中感谢 Gary Russell 为我之前的问题提供了答案,
@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;
}
提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将通过将网关返回的文件名列表发送到
nullChannel
来丢弃该列表。在那里添加另一个 .handle() 方法 - 消息负载是远程路径列表。
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.