骆驼处理后如何重命名和移动FTP上的文件? [英] How to rename and move the file on FTP once processed by camel?

查看:44
本文介绍了骆驼处理后如何重命名和移动FTP上的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 ftp 上有几个文件夹:

/csv/xml/处理/....

如何将每个文件从 file.csv 处理到 file.done 并将其移动到已处理文件夹后重命名和移动?我已经尝试了很多选项,比如向from"添加大量参数,或者在 onCompletion 中添加一些东西,或者添加更多的路由来移动文件.所有占位符都包含正确的值并由 Spring 处理.

<路线><from uri="ftp://{{ftp.user}}@{{ftp.server}}/{{inbound.csv}}?password={{ftp.pass}}&amp;binary=true&amp;include=.*csv"/><onCompletion onCompleteOnly="true"><to uri="ftp://{{ftp.user}}@{{ftp.server}}/{{outbound.csv}}?password={{ftp.pass}}&amp;doneFileName=${文件:名称}.done"/></onCompletion><延迟><常数>15000</常数></延迟><unmarshal><csv/></unmarshal><to uri="bean:cSVHandler?method=process"/></路线>

请帮忙.

解决方案

使用移动选项,在处理完文件后移动/重命名文件,

<from uri="ftp://{{ftp.user}}@{{ftp.server}}/{{inbound.csv}}?password={{ftp.pass}}&amp;binary=true&amp;include=.*csv&amp;move=../已处理"/>

这会将文件移动到 ../processed 目录中.

http://camel.apache.org/file2 上查看有关移动选项的更多详细信息/p>

I have several folders on my ftp:

/csv
/xml
/processed
/....

How can I rename and move each file once it has been processed from file.csv to file.done and move it to processed folder ? I have tried many options like adding tons of parameters to "from" or add something into onCompletion or adding several more routes for just moving files. All placeholders contain correct values and are processed by Spring.

<route>
            <from uri="ftp://{{ftp.user}}@{{ftp.server}}/{{inbound.csv}}?password={{ftp.pass}}&amp;binary=true&amp;include=.*csv"/>
            <onCompletion onCompleteOnly="true">
                <to uri="ftp://{{ftp.user}}@{{ftp.server}}/{{outbound.csv}}?password={{ftp.pass}}&amp;doneFileName=${file:name}.done"/>
            </onCompletion>
            <delay>
                <constant>15000</constant>
            </delay>
            <unmarshal><csv/></unmarshal>
            <to uri="bean:cSVHandler?method=process"/>
        </route>

Please help.

解决方案

Use the move option which will move/rename the file after its processed,

<from uri="ftp://{{ftp.user}}@{{ftp.server}}/{{inbound.csv}}
      ?password={{ftp.pass}}&amp;binary=true&amp;include=.*csv
      &amp;move=../processed"/>

Which will move the file into the ../processed directory.

See more details about the move option at http://camel.apache.org/file2

这篇关于骆驼处理后如何重命名和移动FTP上的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆