You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by boday <be...@initekconsulting.com> on 2011/06/16 23:45:06 UTC
Re: Getting file from ftp
why not just use a route to do this? see http://camel.apache.org/ftp2.html
camel-ftp for more information...
basically just like this though...
from("ftp://someone@someserver.com?password=secret&localWorkDirectory=/tmp").to("file://inbox");
laxad wrote:
>
> I am a new user to Camel and I am having difficulty getting files out of
> FTP. I followed this wonderful tutorial:
> http://blog.jayway.com/2010/08/12/dynamic-ftp-client-using-apache-camel-and-spring/
> to get a feel for what it camel and I can put ftp files on the server from
> my local desktop. I would like to retrieve them. I went through the
> previous posts and tried different methods.
>
> What I have right now is this ...
>
> public static void main(){
>
> camelContext context = new DefaultCamelContext();
> context.start();
> ProducerTemplate prodTempl = context.getProdTemplate();
> ConsumerTemplate consTempl = context.getConsTemplate();
> File file = new File("files/test.txt");
> File getFile = null;
> if (file.exists()) {
> logger.info("file does exist");
> FtpProps = new FTPSImplementation(username, host, password,
> false);
> ProducerTemplate prodTemplate =
> context.createProducerTemplate();
> ConsumerTemplate consumerTemplate =
> context.createConsumerTemplate();
>
> //FtpSender = new FTPSSenderImplementation(prodTemplate);
> //FtpSender.sendFile(FtpProps, file);
> //it successfully transmits the file called test.txt (so this
> file exists on the ftp server)
> FtpGetter = new FTPSGetterImplementation(consumerTemplate);
> getFile = FtpGetter.getFile(FtpProps);
> }
> }
>
> and getFile function looks like this
>
> public File getFile(FtpProperties ftpProperties){
> logger.info("In the getFile() method");
> String createFtpURI = createFtpURI(ftpProperties);
> //ftpURI ends up looking like this:
> ftps://test@ftpserver:21?isImplicit=false&password=******
> File file = consumerTemplate.receiveBodyNoWait(createFtpURI,
> File.class);
> return file;
>
> }
>
-----
Ben O'Day
IT Consultant -http://consulting-notes.com
--
View this message in context: http://camel.465427.n5.nabble.com/Getting-file-from-ftp-tp4496607p4496817.html
Sent from the Camel - Users mailing list archive at Nabble.com.