Camel: the file component, but only the file name as the body

I am trying to process potentially large files with Camel, and I am worried that they are "customized" in the body of Camel Message . Is there a way that I can simply pass the name (path) of the file as the body of the message, and then use it on the processor to read from disk?

+6
source share
1 answer

You can just pass an instance of java.io.File. This, in fact, is that the component of the Camel file itself (although it is located inside the WrappedFile, due to the sharing of code with ftp components).

Of course, you can just save the file name as a String, and then from the processor access the file either with

 String name = exchange.getIn().getBody(String.class); File file = new File(name); ... FileInputStream fis = new FileInputStream(file); // read the file from the stream, etc. 
+9
source

Source: https://habr.com/ru/post/909009/


All Articles