0

I have to download a file which is in remote location using SFTP on clicking a hyperlink . Am using JBOSS 5.1 as my Server and using struts2. I have implemented the below code and i found out the receiveBody() of the ConsumerTemplate is coming as null ? Can any one please guide me to the above issue ?

Code :

CamelContext ctx = new DefaultCamelContext();
                ConsumerTemplate consumer = ctx.createConsumerTemplate();
                String camel_ftp_uri = MessageFormat.format(CAMEL_FTP_PATTERN, ftp_mode, ftp_user, ftp_address, ftp_dir, ftp_options);
                System.out.println("camel_ftp_uri ::: "+camel_ftp_uri);

                Object obj= consumer.receiveBody(camel_ftp_uri);
                System.out.println("obj  ::"+obj);

when am printing the camel_ftp_uri am getting :camel_ftp_uri :::

ftp://ccc_uat1@1x.xxx.xx.xxx//from_ccc/file.txt?disconnect=true

I refered the below link in SOF :

How to retrieve a file from a server via SFTP?

Thanks in Advance

Community
  • 1
  • 1
Esh
  • 836
  • 5
  • 16
  • 43
  • This isn't a question, it's a "do my work for me" request. What have you already tried, and what problems have you run into? – Omaha Aug 24 '12 at 11:31
  • @Omaha Thank you for your kind consideration . I have clearly mentioned am new to SFTP and am not getting what they mentioned in the link given – Esh Aug 24 '12 at 11:34
  • Have a read of http://serverfault.com/questions/176149/how-to-provide-a-web-interface-to-sftp-server and see if that helps – Anthony Palmer Aug 24 '12 at 11:37

1 Answers1

1

The Camel FTP component you have to configure the ftp uri with a starting directory, and then provide the file name to download as a seperate parameter. What you do wrong is that the starting directory is the file name.

This

ftp://ccc_uat1@1x.xxx.xx.xxx//from_ccc/file.txt?disconnect=true

Should be changed to

ftp://ccc_uat1@1x.xxx.xx.xxx//from_ccc/?disconnect=true&fileName=file.txt
Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65