我正在使用Spring Integration从FTP服务器下载/上传文件。
如何在Spring FTP中动态更改remote-directory="/directory Name"
:Inbound-Channel。
我的客户端每天都会以"MM-dd-yy"
格式创建一个文件夹,并将所有文件复制到那里。
在“FTP:Inbound-channel”中,我没有找到任何方法来配置此模式。我基本上有
在配置中硬编码目录或文件名。
我想要的是以编程方式设置路径。因为有时我需要下载所有文件
从一个目录或只下载一个特定的文件。
我发现可以在FTP中设置"remote-directory-expression="'directory'+'/'+ new java.text.SimpleDateFormat('dd-MM-yyyy').format(new java.util.Date())"
:出站通道
在FTP中有任何这样的属性:InBound-channel
我的配置是这样的:
<bean id="ftpClientFactory"
class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
<property name="host" value="${host}" />
<property name="port" value="${availableServerPort}" />
<property name="username" value="${userid}" />
<property name="password" value="${password}" />
</bean>
<int-ftp:inbound-channel-adapter id="ftpInbound"
cache-sessions="false" channel="ftpChannel" session-factory="ftpClientFactory"
filename-pattern="*.txt" auto-create-local-directory="true"
delete-remote-files="false" remote-directory="/filedirectory"
local-directory="${local_directory}">
<int:poller fixed-rate="1000" />
</int-ftp:inbound-channel-adapter>
<int:channel id="ftpChannel">
<int:queue />
</int:channel>
我没有办法完成上述所有项目。
请让我知道如何实现这一目标。
答案 0 :(得分:1)
您无法使用入站适配器执行此操作,但<ftp:outbound-gateway/>可用于实现您的需求;描述here。
您可以使用ls
列出文件,使用<splitter/>
和另一个使用get
的网关;或者您可以在表达式中使用带有文件名模式的mget
命令。
FTP sample有一个使用网关的例子