Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Camel: "file" component, but only pass file name as body

Tags:

apache-camel

I'm trying to process potentially large files using Camel, and am worried about them "fitting" in the body of a Camel Message. Is there a way I can just pass the name (path) of the file as the body of the message, and then in a processor use that to read from disk?

like image 270
Tonio Avatar asked Feb 21 '12 19:02

Tonio


1 Answers

You can just pass in a java.io.File instance. This is essentially what the Camel file component does itself (although its placed inside a WrappedFile, due sharing code with the ftp components).

You can of course also just store the name of the file as a String, and then from the processor access the file, either by

String name = exchange.getIn().getBody(String.class);
File file = new File(name);
...
FileInputStream fis = new FileInputStream(file);
// read the file from the stream, etc.
like image 101
Claus Ibsen Avatar answered Sep 22 '22 22:09

Claus Ibsen