how to get file with int-ftp:outbound-gateway and remove from server if exists?

北城余情 提交于 2020-03-06 03:20:09

问题


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 for help me.


回答1:


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.

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.

Or, you can use LS to get the file names, remove them, and then do the mget.



来源:https://stackoverflow.com/questions/29766471/how-to-get-file-with-int-ftpoutbound-gateway-and-remove-from-server-if-exists

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!