I have a Camel route with FTP and Bean component which processes the message. This message is a file on FTP and I would like to get the filename of each file processed. I know how to get files with parameter String, but then I cannot get the filename. Thanks for the answer.
1
votes
1 Answers
1
votes
The Camel FTP component extends the File component, the File Component adds the following headers when consuming a file:
CamelFileName
: Name of the consumed file as a relative file path with offset from the starting directory configured on the endpoint.CamelFileNameOnly
: Only the file name (the name with no leading paths).
You can check out the other available headers in the "File consumer only" section of the File2 documentation page.
In a bean method, you can pass a specific header as a parameter using the @Simple
annotation giving it the value "header.<header name>"
. For example:
public void processFile(@Body String fileContent, @Simple("header.CamelFileNameOnly") String fileName){
// your method implementation
}