spring sftp 在没有本地目录的远程读写
spring sftp read and write in remote without local directory
我知道如何使用 spring-integration-sftp 从 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"/>
我尝试删除标签 local-directory 元素,但 spring 不允许这样做,有没有办法在不创建文件的情况下读写文件在本地目录中?
有没有办法指定多个不区分大小写的文件扩展名类型?
您可以使用出站网关(带 -stream
选项的 get
命令)将远程文件作为 InputStream
.
请注意,从流中读取文件内容后,您有责任关闭会话。
对于文件入站适配器上的不区分大小写的匹配,使用正则表达式而不是简单模式:filename-regex="(?i).*\.txt"
.
出站网关没有模式匹配;您必须使用 ls
命令来列出文件并获取您想要的文件。 sftp sample 展示了如何做到这一点。
我知道如何使用 spring-integration-sftp 从 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"/>
我尝试删除标签 local-directory 元素,但 spring 不允许这样做,有没有办法在不创建文件的情况下读写文件在本地目录中?
有没有办法指定多个不区分大小写的文件扩展名类型?
您可以使用出站网关(带 -stream
选项的 get
命令)将远程文件作为 InputStream
.
请注意,从流中读取文件内容后,您有责任关闭会话。
对于文件入站适配器上的不区分大小写的匹配,使用正则表达式而不是简单模式:filename-regex="(?i).*\.txt"
.
出站网关没有模式匹配;您必须使用 ls
命令来列出文件并获取您想要的文件。 sftp sample 展示了如何做到这一点。