当文件对象是目录时,如何将 SFTP Spring Integration mput 与 SftpOutboundGateway 一起使用?

问题描述 投票:0回答:1
    <int-sftp:outbound-gateway session-factory="sftpSessionFactory"
                               use-temporary-file-name="false"
                               request-channel="tmpDirToUploadOutputChannel"
                               command="mput"
                               expression="payload"
                               remote-directory="/out"
                               reply-channel="sftpUploadFilesResultChannel">
    </int-sftp:outbound-gateway>`

当我从服务激活器发送消息时 - 文件是包含文件的目录

        val message = MessageBuilder
            .withPayload(tmpOutFile)
//            .setHeader("file_name", tmpOutFileName)
            .build()

出站网关使用最后一个文件名,在服务器上我只能看到服务器上的一个文件

如何正确使用并使用所有文件名?

我来自服务激活器的消息

enter image description here

spring-integration spring-integration-sftp
1个回答
1
投票

尤里卡!

inbound-channel-adapter --> service-activator 返回消息文件是目录 --> sftp outbound-gateway

sftp 出站网关将来自入站通道适配器的文件名缓存在标头 file_name 中

当我设置“file_name”时,“”

        val message = MessageBuilder
            .withPayload(File(tmpOutDirPath))
            .setHeader("file_name", "")
            .build()

在这种情况下,removeHeader 也不起作用

© www.soinside.com 2019 - 2024. All rights reserved.