如何在 ftp 出站网关中进行 mput 操作后获取文件列表?

发布于 2025-01-15 22:50:53 字数 1046 浏览 5 评论 0原文

我设法将文件从本地 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苯莒 2025-01-22 22:50:53

您将通过将网关返回的文件名列表发送到 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文