How to rename and move the file on FTP once proces

2019-08-04 07:14发布

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.

1条回答
太酷不给撩
2楼-- · 2019-08-04 07:47

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

查看更多
登录 后发表回答