Spring integration Spring集成ftp在自定义筛选器中获取整个文件
我有一个使用ftp入站通道适配器拾取文件的应用程序。我无法将acceptoncefilefilter与它一起使用。因此,我可以对照自己存储的数据检查文件。数据是文件的sha密钥 我的问题是,我使用的customfilefilter只获取FTPFile,而不是实际的文件。因此,我无法为它生成SHA密钥 这是相关的配置Spring integration Spring集成ftp在自定义筛选器中获取整个文件,spring-integration,Spring Integration,我有一个使用ftp入站通道适配器拾取文件的应用程序。我无法将acceptoncefilefilter与它一起使用。因此,我可以对照自己存储的数据检查文件。数据是文件的sha密钥 我的问题是,我使用的customfilefilter只获取FTPFile,而不是实际的文件。因此,我无法为它生成SHA密钥 这是相关的配置 <int-ftp:inbound-channel-adapter id="ftpInbound" channel="ftpChannel" sessio
<int-ftp:inbound-channel-adapter id="ftpInbound"
channel="ftpChannel"
session-factory="ftpClientFactory"
charset="UTF-8"
local-directory="c:\DMSRoot"
temporary-file-suffix=".writing"
remote-directory="DMS"
preserve-timestamp="true"
auto-startup="true"
filter="compositeFilterRemote">
<int:poller fixed-delay="5000" error-channel="errorChannel"/>
</int-ftp:inbound-channel-adapter>
<int-ftp:outbound-channel-adapter id="ftpOutbound"
channel="ftpChannel"
session-factory="ftpClientFactory"
charset="UTF-8"
remote-file-separator="/"
auto-create-directory="true"
remote-directory="DMS"
use-temporary-file-name="true"
temporary-file-suffix=".writing">
<int-ftp:request-handler-advice-chain>
<bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
<property name="onSuccessExpression" value="new File(payload).delete()" />
<property name="onFailureExpression" value="new File(payload).delete()" />
</bean>
</int-ftp:request-handler-advice-chain>
</int-ftp:outbound-channel-adapter>
<bean id="compositeFilterRemote" class="org.springframework.integration.file.filters.CompositeFileListFilter">
<constructor-arg>
<list>
<!-- Ensures that the file is whole before processing it -->
<bean class="org.springframework.integration.file.filters.AcceptAllFileListFilter" />
<bean class="com.polling.util.CustomFileFilterRemote"/>
<!-- Ensures files are picked up only once from the directory -->
</list>
</constructor-arg>
</bean>
public class CustomFileFilterRemote implements FileListFilter<FTPFile>
{
@Override
public List<FTPFile> filterFiles(FTPFile[] files)
{
公共类CustomFileFilterRemote实现FileListFilter
{
@凌驾
公共列表筛选器文件(FTPFile[]文件)
{
请告诉我如何完成此操作?您必须首先获取文件以计算sha-有两个筛选器-一个用于决定是否应获取文件(我们只接收文件元数据,如ls)。获取文件后,第二个筛选器(
本地筛选器
)用于文件系统文件。非常感谢任何帮助。请更具体一些。FTPClient.listFiles
准确返回FTPFile[]
。关于实际文件,您是什么意思?FTPFile是一个参考文件,对吗?它实际上不是一个文件。我希望内容是指java.io.file来生成sha密钥。我希望仅使用FTPFile提供的信息来完成此操作,所以我只在过滤器和本地过滤器中添加模式评估要实际检查文件,可能需要获取sha等?对,但要知道每次都要获取整个文件;继续获取大文件可能会很昂贵。