我正在使用Spring集成从FTP服务器下载/上载文件。从FTP服务器下载动态更改目录的文件
如何在Spring FTP中动态更改remote-directory="/directory Name"
:入站通道。
我的客户将基本上每天创建一个文件夹,格式为"MM-dd-yy"
,并将所有文件复制到那里。 在“FTP:入站通道”中,我没有找到任何方式来配置此模式。我基本上有 硬编码配置中的目录或文件名。 我想要的是以编程方式设置路径。因为有时候我需要从一个direcotory下载所有文件 或者只下载一个特定的文件。
我发现"remote-directory-expression="'directory'+'/'+ new java.text.SimpleDateFormat('dd-MM-yyyy').format(new java.util.Date())"
可以在FTP设置:出站通道 有在FTP任何这样的属性:入站通道
我的配置是这样的:
<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>
我没有找到一个方式来做所有上述项目。
请让我知道我该怎么做到这一点。