问题描述
感谢关注
i使用 int-ftp:outbound-gateway
与 mget
命令,我想当从服务器检索文件,如果从服务器检索的文件存在于本地目录然后抛出波纹管异常:
thanks for attention
i used int-ftp:outbound-gateway
with mget
command, i want to when retrieve file from server if file that retrieve from server exists in local directory then thrown bellow exception :
org.springframework.messaging.MessagingException: Local file .\backup\a\in\a.in already exists
适配器代码为:
adapter code is:
<int-ftp:outbound-gateway id="gatewayGET"
local-directory-expression="'./backup/' +#remoteDirectory"
session-factory="ftpSessionFactory"
request-channel="toGet"
reply-channel="toRemoveChannel"
command="mget"
command-options="-R"
expression="payload.remoteDirectory + '/' + payload.filename"/>
thans帮助我。
推荐答案
当文件已存在于本地时,目前无法忽略该错误,请打开,我们可以添加一个选项到网关。
There's currently no way to ignore the error when a file already exists locally, please open a new feature JIRA issue and we can add an option to the gateway.
与此同时,我能想到的一个解决方法是 mget
>它们到一个临时目录,并使用文件出站通道适配器将文件移动到最终目录 - 它有一个选项可以覆盖(替换)任何现有文件,同时删除临时文件。
In the meantime, one workaround I can think of is to mget
them to a temporary directory and use a file outbound channel adapter to "move" the file to the final directory - it has an option to overwrite (replace) any existing file, while removing the temporary file.
或者,您可以使用LS获取文件名,将其删除,然后执行mget。
Or, you can use LS to get the file names, remove them, and then do the mget.
这篇关于如何使用int-ftp获取文件:outbound-gateway并从服务器中删除(如果存在)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!