Skip to main content

Fetch files from an SFTP server

Camel has an SFTP component (see Camel documentation) that enables fetching files from an SFTP server. A simple SFTP route for fetching files can look like this:

<routes xmlns="http://camel.apache.org/schema/spring">
  <route id="example.sftp.fa">
    <from uri="sftp://fa@123.45.67.891/inbox/files?username=fa&amp;password=1234&amp;reconnectDelay=10000&amp;delay=60000&amp;disconnect=true&amp;delete=true" />
    <to uri="file:{{back.writable.dir}}/integrations/custom?autoCreate=true" />
  </route>
</routes>

The above route:

  • Fetches (copies) files from the SFTP server "123.45.67.891/inbox/files" directory (authenticating with username and password, polling once every 60 seconds).

  • Places the files to the /integrations/custom FA directory.

  • Deletes the original files from the SFTP server directory after successful processing.

You might need to apply other SFTP connection parameters as well depending on the requirements of the SFTP server you connect to.