bobito
bobito

Reputation: 11

camel file component how to send entire folder

I have the following folder hierarchy :

Using Camel file component, I would like to send the repertory D1 and its content to another endpoint. So far I manage to send file independently or a whole content of a repertory, but I don't know how to send with the prvious structure the repertory D1 and its content (not just the content)

To send all the content of D1, i am writing :

from("file://D/D1/?noop=true&recursive=true").to(.....)

and it sends everything inside D1 correctly. Now to send D1 as a full directory with the contents, I tried :

from("file://D/?fileName=D1&noop=true&recursive=true").to(.....)

of course not working as camel file is apparently designed to work for file only and not directories like I saw on this link :

http://grokbase.com/t/camel/users/1485bjq5zr/polling-a-directory-for-inner-directories

However, it looks annoying and strange to me as I have to make a hack changing the previous hierarchy into :

so that when I use :

from("file://D/D1/?noop=true&recursive=true").to(.....)

it finally does what I want sending the directory as well. Is there really not a cleaner way to do this ? If no, what is the reason behind ?

Upvotes: 1

Views: 1011

Answers (2)

Clover
Clover

Reputation: 549

It's a kinda old thread but I'm sure it will help someone

from("file:D:\\INPUTFOLDER?noop=false&recursive=true&maxDepth=NUMBEROFSUBDIR").process(new MyProcessor()).to("file:D:\\OUTPUTFOLDER");

in here NUMBEROFSUBDIR.. will be +1 from the main directory(INPUTFOLDER) and it won't copy the folder unless you have file present in it, as it supports FTP.

Upvotes: 0

Claus Ibsen
Claus Ibsen

Reputation: 55750

Use recursive to tell Camel to travel down sub directories. And you can use the min/max depth options to control from and how far you go down.

This is the clean solution using the correct options for what they are intended.

For example on unix the find command also has minx/max depth options and its the similar concept in the Camel file component.

More details at: http://camel.apache.org/file2

And if you do not want to build the directory structured on the 'other side' you can use the flattern option.

Upvotes: 2

Related Questions