我知道如何使用以下配置从SFTP位置读取和写入spring-integration-sftp:
<bean id="sftpSessionFactory"
class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory"
p:host="${host}"
p:port="${port}"
p:user="${username}"
p:password="${password}"
p:allowUnknownKeys="true" />
<int:channel id="sftpChannel">
<int:queue />
</int:channel>
<int-sftp:inbound-channel-adapter
id="sftpInboundAdapter"
channel="sftpChannel"
session-factory="sftpSessionFactory"
remote-directory="${remote.dir}"
local-directory="${local.dir}" <-- i don't want
auto-create-local-directory="false"
delete-remote-files="false"
filename-pattern="*.TXT" <-- how to specify multiple type
local-filter="acceptOnceFilter">
</int-sftp:inbound-channel-adapter>
<bean id="acceptOnceFilter"
class="org.springframework.integration.file.filters.AcceptOnceFileListFilter"/>
<int:poller default="true" fixed-rate="1000" max-messages-per-poll="100" />
<int:service-activator input-channel="sftpChannel" ref="stringHandler" method="handleMessage"/>
<bean id="stringHandler" class="com.core.sftp.StringHandler"/>我尝试删除标记本地目录元素,但是spring不允许这样做,有没有一种方法可以在不创建本地目录的情况下读取和写入文件?
是否有一种方法可以指定多个文件扩展名类型而不区分大小写?
发布于 2016-03-11 13:55:00
您可以使用出站网关(get命令和-stream选项)作为InputStream获取远程文件。
请注意,一旦从流读取了文件内容,您就负责关闭会话。
见这里的文档。
对于文件入站适配器上不区分大小写的匹配,请使用regex而不是简单的模式:filename-regex="(?i).*\.txt"。
没有与出站网关匹配的模式;您必须使用ls命令列出文件并获取所需的文件。sftp样品展示了如何做到这一点。
https://stackoverflow.com/questions/35931594
复制相似问题