Reputation: 220
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}}&binary=true&include=.*csv"/>
<onCompletion onCompleteOnly="true">
<to uri="ftp://{{ftp.user}}@{{ftp.server}}/{{outbound.csv}}?password={{ftp.pass}}&doneFileName=${file:name}.done"/>
</onCompletion>
<delay>
<constant>15000</constant>
</delay>
<unmarshal><csv/></unmarshal>
<to uri="bean:cSVHandler?method=process"/>
</route>
Please help.
Upvotes: 1
Views: 9329
Reputation: 463
In case someone finds this post and does only want to rename the file, you can add
&move=${headers.CamelFileName}.old
Upvotes: 4
Reputation: 55540
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}}&binary=true&include=.*csv
&move=../processed"/>
Which will move the file into the ../processed directory.
See more details about the move option at http://camel.apache.org/file2
Upvotes: 4