You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Aida <ai...@gmail.com> on 2012/11/30 14:50:14 UTC

[FTP2] Problems transversing directories when uploading files with SFTP (Camel 2.9.4)

Hi,

I have been having trouble trying to upload files using a sftp endpoint.

The way I'm working to upload a file is using a ProducerTemplate ( 
ProducerTemplate.send(endPointDefinition, data2write) where data2write is
the Exchange with the data I want to upload ). This way works for me working
with FTP servers and "ftp://***" endpoints, but when trying to use a server
that needs SFTP, the connection is made successfully, but there is a
failure/exception when tries to access to the directory where the file
should be uploaded.

I have seen that the reason of this behaviour is that the name of the folder
I want to use haven´t got the first character, so if the folder was
"myFolder", it tries to  change the directory to "yFolder". The message I
can retrieve from the received Exchange is "Cannot change directory to:
yFolder". However, the endpoint is wellformed. I'm sure of this because I
see it in the log trace (set at INFO level), example:

2012-11-30 12:33:35,414 INFO 
[org.apache.camel.component.file.remote.RemoteFileProducer] (Camel
(processesCamelContext) thread #12 - JmsConsumer[App_JOBS_QUEUE_IN])
Connected and logged in to:
Endpoint[sftp://myFtpHost@XXX.XX.XXX.XX:22/myFolder?charset=ISO-8859-1&delay=2000&disconnect=true&fileName=myFileName.xml&initialDelay=0&password=******&separator=Auto]
2012-11-30 12:33:35,537 WARNING
[org.apache.camel.component.file.remote.RemoteFileProducer] (Camel
(processesCamelContext) thread #12 - JmsConsumer[App_JOBS_QUEUE_IN]) Writing
file failed with: Cannot change directory to: yFolder

I don´t know if it could be a kind of "escape characters issue", but I put
here the results of some tests:

1. Endpoint: sftp://myFtpHost@XXX.XX.XXX.XX:22/myFolder?charset= ...
   Result message: Cannot change directory to: yFolder
   
2. Endpoint:  sftp://myFtpHost@XXX.XX.XXX.XX:22/mmyFolder?charset= ...
   Result message: Cannot change directory to: myFolder   -> here the dir
name is OK but it still fails (and strictly the endpoint it´s not correct)
   
3. Endpoint:  sftp://myFtpHost@XXX.XX.XXX.XX:22//myFolder?charset= ...
	Result message: Cannot change directory to: yFolder
	

I have tried with two different separators (Auto and UNIX) when building the
endpoint, but the result is the same.	

Looking into the FTP2 component documentation, I have found a way to make it
work. This is using the stepwise option set to false. This way works, but
what worries me is that (for security issues) not all the FTP servers allow
this option.	

Additional Info:
	Apache Camel version: 2.9.4
	Camel processes running on Windows machine
	FTP where files are uploaded running on Linux machine, using SFTP

Maybe I'm missing something. Any help would be appreciated.

Thanks in advance.

  Aida.
	



--
View this message in context: http://camel.465427.n5.nabble.com/FTP2-Problems-transversing-directories-when-uploading-files-with-SFTP-Camel-2-9-4-tp5723456.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: [FTP2] Problems transversing directories when uploading files with SFTP (Camel 2.9.4)

Posted by Aida <ai...@gmail.com>.
Thanks Leandro.

Thank you for the response Claus, yes I'm sure that the folder "myFolder" is
a sub-dir of the home dir. The same scenary with a "standard" ftp (no sftp
endpoint) works perfectly but in this case if I don´t use the stepwise
option there is no way to write in that dir.





--
View this message in context: http://camel.465427.n5.nabble.com/FTP2-Problems-transversing-directories-when-uploading-files-with-SFTP-Camel-2-9-4-tp5723456p5723552.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: [FTP2] Problems transversing directories when uploading files with SFTP (Camel 2.9.4)

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

The ftp consumer will login to the users "home" directory by default.
And then CD into any sub-dirs you may specify.

Are you sure "myFolder" is a sub dir of the home dir. If not then you
don't need to specify that.
For example maybe you only need to download files from the home dir.
And then the url is just

sftp://myFtpHost@XXX.XX.XXX.XX:22?charset=ISO-8859-1....


On Fri, Nov 30, 2012 at 2:50 PM, Aida <ai...@gmail.com> wrote:
> myFolder



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: [FTP2] Problems transversing directories when uploading files with SFTP (Camel 2.9.4)

Posted by Leandro Franchi <le...@gmail.com>.
I undestand...

I've got this message two times. First, when I didin't have permission and
the second when I didn't terminate the url with a slash.

I hope the best
Leandro Franchi




On Mon, Dec 3, 2012 at 6:32 AM, Aida <ai...@gmail.com> wrote:

> Hi Leandro,
>
> Yes, I have the correct permissions. As I said I'm able to login on the
> server, and with the stepwise option I have no problem in writing a file.
> The problem comes once camel has logged in the FTP and tries to access to a
> directory that it isn´t the one specified in the endpoint.
>
> Thanks.
>
>   Aida.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/FTP2-Problems-transversing-directories-when-uploading-files-with-SFTP-Camel-2-9-4-tp5723456p5723520.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
*Leandro Franchi*
http://www.frango10.com

Re: [FTP2] Problems transversing directories when uploading files with SFTP (Camel 2.9.4)

Posted by Aida <ai...@gmail.com>.
Hi Leandro,

Yes, I have the correct permissions. As I said I'm able to login on the
server, and with the stepwise option I have no problem in writing a file.
The problem comes once camel has logged in the FTP and tries to access to a
directory that it isn´t the one specified in the endpoint.

Thanks.

  Aida.



--
View this message in context: http://camel.465427.n5.nabble.com/FTP2-Problems-transversing-directories-when-uploading-files-with-SFTP-Camel-2-9-4-tp5723456p5723520.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: [FTP2] Problems transversing directories when uploading files with SFTP (Camel 2.9.4)

Posted by Leandro Franchi <le...@gmail.com>.
Ainda,

Do you have the correct permissions on the server?


Best Regards
Leandro Franchi


On Fri, Nov 30, 2012 at 11:50 AM, Aida <ai...@gmail.com> wrote:

> Hi,
>
> I have been having trouble trying to upload files using a sftp endpoint.
>
> The way I'm working to upload a file is using a ProducerTemplate (
> ProducerTemplate.send(endPointDefinition, data2write) where data2write is
> the Exchange with the data I want to upload ). This way works for me
> working
> with FTP servers and "ftp://***" endpoints, but when trying to use a
> server
> that needs SFTP, the connection is made successfully, but there is a
> failure/exception when tries to access to the directory where the file
> should be uploaded.
>
> I have seen that the reason of this behaviour is that the name of the
> folder
> I want to use haven´t got the first character, so if the folder was
> "myFolder", it tries to  change the directory to "yFolder". The message I
> can retrieve from the received Exchange is "Cannot change directory to:
> yFolder". However, the endpoint is wellformed. I'm sure of this because I
> see it in the log trace (set at INFO level), example:
>
> 2012-11-30 12:33:35,414 INFO
> [org.apache.camel.component.file.remote.RemoteFileProducer] (Camel
> (processesCamelContext) thread #12 - JmsConsumer[App_JOBS_QUEUE_IN])
> Connected and logged in to:
> Endpoint[sftp://myFtpHost@XXX.XX.XXX.XX
> :22/myFolder?charset=ISO-8859-1&delay=2000&disconnect=true&fileName=myFileName.xml&initialDelay=0&password=******&separator=Auto]
> 2012-11-30 12:33:35,537 WARNING
> [org.apache.camel.component.file.remote.RemoteFileProducer] (Camel
> (processesCamelContext) thread #12 - JmsConsumer[App_JOBS_QUEUE_IN])
> Writing
> file failed with: Cannot change directory to: yFolder
>
> I don´t know if it could be a kind of "escape characters issue", but I put
> here the results of some tests:
>
> 1. Endpoint: sftp://myFtpHost@XXX.XX.XXX.XX:22/myFolder?charset= ...
>    Result message: Cannot change directory to: yFolder
>
> 2. Endpoint:  sftp://myFtpHost@XXX.XX.XXX.XX:22/mmyFolder?charset= ...
>    Result message: Cannot change directory to: myFolder   -> here the dir
> name is OK but it still fails (and strictly the endpoint it´s not correct)
>
> 3. Endpoint:  sftp://myFtpHost@XXX.XX.XXX.XX:22//myFolder?charset= ...
>         Result message: Cannot change directory to: yFolder
>
>
> I have tried with two different separators (Auto and UNIX) when building
> the
> endpoint, but the result is the same.
>
> Looking into the FTP2 component documentation, I have found a way to make
> it
> work. This is using the stepwise option set to false. This way works, but
> what worries me is that (for security issues) not all the FTP servers allow
> this option.
>
> Additional Info:
>         Apache Camel version: 2.9.4
>         Camel processes running on Windows machine
>         FTP where files are uploaded running on Linux machine, using SFTP
>
> Maybe I'm missing something. Any help would be appreciated.
>
> Thanks in advance.
>
>   Aida.
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/FTP2-Problems-transversing-directories-when-uploading-files-with-SFTP-Camel-2-9-4-tp5723456.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
*Leandro Franchi*
http://www.frango10.com