Question

Being new to Apache Camel, I have been following the examples all over the internet. Near on every book/forum/bog post has an example on how to create a simple route that will consume/produce files to/from an FTP server.

My issue is that the host that I am trying to connect to using the suggested connection

from("ftp://someone@someserver.com?password=secret&localWorkDirectory=/tmp")

OR

<from uri="ftp://someone@someserver/public/reports?password=password"/>

Doesn't work for me when I use the credentials my host supplies me:

For the sake of this example, lets call the FTP details:

FTP username: username@ftpserverhost.com Password: password

So when I replace the advised URI with my servers credentials it fails to connect. I am assuming this is because it has two @ symbols and this is causing the route some confusion.

from("ftp://username@ftpserverhost.com@ftpserverhost.com?password=secret&localWorkDirectory=/tmp")

OR

<from uri="ftp://username@ftpserverhost.com@ftpserverhost.com/public/reports?password=password"/>

Is there a way to escape the @ or get this working? I have asked my host if its possible to leave the @ftpserverhost.com but they have advised me that it will not work.

Any ideas?

Was it helpful?

Solution

Use the username option:

from("ftp://ftpserverhost.com?password=secret&localWorkDirectory=/tmp&username=username@ftpserverhost.com")

If this does not work and if you use Camel 2.11 or above, you may use the RAW syntax:

from("ftp://ftpserverhost.com?password=secret&localWorkDirectory=/tmp&username=RAW(username@ftpserverhost.com)")

The RAW syntax also comes in handy if your options contains &, + or other special characters that must not be encoded.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top