chrislovecnm
chrislovecnm

Reputation: 2621

Camel File Endpoint - Getting the file name

I have a camel route:

from("file:///u01/www/images/nonprofits-test?move=.done&preMove=.processing&filter=#nonpFileFilter&minDepth=2&recursive=true")

Later on in the route I need to access the origin file name. How do I get that information? All of the headers contain information in like ${file:name}, but not the actual file name.

Thanks in advance!

The base problem is that simple language is not being evaluated correctly in while running Camel with grails. This is being discussed further on the Camel user list.

Upvotes: 4

Views: 33068

Answers (3)

Guru Tata
Guru Tata

Reputation: 391

${headers.CamelFileName} will provide you with the CamelFileName that is read for processing. We have many other header properties that you can find from the Camel Documentation.

Upvotes: 1

Khader M A
Khader M A

Reputation: 6311

If your simple language is not working it would be because you are not using <simple> tag try something like below.

     <route id="movedFailedFileForRetry">
        <from uri="file:///opt/failed?delete=true" />
        <log loggingLevel="INFO" message="Moving failed file ${header.CamelFileName} for retry" />
        <choice>
            <when>
            <simple>${headers.CamelFileName} == 'file1.txt'</simple>
            <to uri="file:///opt/input1" />
            </when>
            <otherwise>
            <to uri="file:///opt/input2" />
            </otherwise>
        </choice>
     </route>

Hope it helps!!

Upvotes: 2

Ben ODay
Ben ODay

Reputation: 21015

there is a header called "CamelFileName" that stores this

see camel-file2 headers section for more details...

Upvotes: 13

Related Questions