camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: How to use File endpoint to write files to directories in form of 1/2/3/4
Date Wed, 09 Feb 2011 10:15:11 GMT
On Wed, Feb 9, 2011 at 11:02 AM, Tom Howe <tomhowe@artcore.com> wrote:
> Hi, first post, loving camel! (Using with akka - akka.io).
>

Welcome to the community.

> I need to write a lot of files using camel to a directory and need to avoid
> the directory getting to big.
>
> My endpoint at the moment is just file:/to/my/dir.
>
> It works ok, except if the harvester of these files goes down for a while
> and the directory gets too many files, bad things happen!
>
> Is there a config option that will create subdirectories below that using
> random numbers to several dirs deep. eg
>
> /to/my/dir/1/4/2/filename
>

No but you can just compute the file name and provide it as the header
with the key: Exchange.FILE_NAME


You can also use a bean to generate some random path and then use a
expression as the file name

file:xxxxx?fileName=${bean:myBean.generateSomething}/${file;name}

See some samples here
http://camel.apache.org/file-language.html

The xxx will have the starting path, so the evaluated value of
fileName would be appended.



> Thanks, Tom
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Mime
View raw message