Reputation: 31
I have maybe a stupid question but how I can to download files from ftp server. I use the route
.from("ftp:/test@localhost:21/?password=test") .to("file:/d:\\test")
I have the error : can not store null body. Why ? I read several examples Where is my error? Thanks
EDIT
I use the route :
.from("direct:xx") .from("ftp://test@localhost:21/?password=test") .to("file://d:\inbox");
And I have the error :
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot write null body to file: d:\inbox\xxxxxxx at org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:237) at org.apache.camel.component.file.GenericFileProducer.writeFile(GenericFileProducer.java:277) at org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:165) at org.apache.camel.component.file.GenericFileProducer.process(GenericFileProducer.java:79)
Upvotes: 0
Views: 2758
Reputation: 1879
Add parameter 'allowNullBody=true' to your TO file endpoint
to("file://d:\test?allowNullBody=true")
If you go deep into source code as state in org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:237)
, you will see the related GenericFileOperationFailedException happens when
By default, allowNullBody in File producer is 'false' as state in Camel File Component. You need to change it to 'true' to allow storage of empty files.
Upvotes: 0
Reputation: 27018
This should work.
.from("ftp://test@localhost:21/?password=test").to("file://d:\\test")
I am pretty sure about the from part. But the to part you might have to change a little bit(wrt '/') because I have not worked on windows
Upvotes: 1