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: Dynamic origin file components?
Date Fri, 28 May 2010 11:10:16 GMT
Hi

Its probably just much easier to create a java.io.File for the file
name and then send that as a body to the given FTP endpoint.
Then you do NOT need any camel routes at all.

And the file will thus be kept as it was.

ProducerTemplate template = ...
File target = new File("the file name here");

template.sendBodyAndHeader(ftpEndpointHere, target,
Exchange.FILE_NAME, "the file name to be written on the ftp server");


On Fri, May 28, 2010 at 12:58 PM, Mattias Severson <matsev@gmail.com> wrote:
>
> Is it possible to create file components dynamically?
>
> I have an interface that gives me File objects (after a physical file has
> been created on disk) that I would like to send to a remote FTP address. The
> files are created one at the time, in different folders and with different
> file names. The files should only be sent once and should also remain on the
> origin location after they have been sent, e.g. by using the noop option.
>
>
>
> void sendViaFtp(File file, String userName, String host) {
>    from(getFileUri(file)).to(getFtpUri(userName, host, file));
> }
>
> private static String getFileUri(File file) {
>    return String.format("file://%s?fileName=%s?noop=true",
> filenameUtils.getPath(file.getAbsolutePath()), file.getName());
> }
>
> private static String getFtpUri(String userName, String host, File file) {
>    return String.format("ftp://%s@%s/%s", userName, host, file.getName());
> }
>
>
>
> --
> View this message in context: http://old.nabble.com/Dynamic-origin-file-components--tp28705368p28705368.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message