Available as of Camel 1.5
The File Expression Language is an extension to the Simple language, adding file related capabilities. These capabilities is related to common use cases working with file path and names. The goal is to allow expression to be used with the File and FTP components for setting dynamic file patterns for both consumer and producer.
This language is an extension to the Simple language so the Simple syntax applies also. So the table below only lists the additional.
All the file tokens uses the same expression name as the method on the java.io.File object, for instance file:absolute refers to the java.io.File.getAbsolute() method. Notice that not all expressions is supported by the current Exchange. For instance the FTP component only supports a few of the options, where as the File component support all of them.
We have a java.io.File handle for the file hello.txt in the following relative directory: .\filelanguage\test. And we configure out endpoint to use this starting directory .\filelanguage. The the file tokens will return as:
We have a java.io.File handle for the file hello.txt in the following absolute directory: \workspace\camel\camel-core\target\filelanguage. And we configure out endpoint to use the absolute starting directory \workspace\camel\camel-core\target\filelanguage. The the file tokens will return as:
You can enter a fixed Constant expression such as myfile.txt:
Lets assume we use the file consumer to read files and want to move the read files to backup folder with the current date as a sub folder. This can be archived using an expression like:
relative folder names is also supported so suppose the backup folder should be a sibling folder then you can append .. as:
As this is an extension to the Simple language we have access to all the goodies from this language also, so in this use case we want to use the in.header.type as a parameter in the dynamic expression:
If you have a custom Date you want to use in the expression then Camel supports retrieving dates from the message header.
And finally we can also use a bean expression to invoke a POJO class that generates some String output (or convertible to String) to be used:
And of course all this can be combined in one expression where you can use the File Language, Simple and the Bean language in one combined expression. This is pretty powerful for those common file path patterns.
The File language is part of camel-core.