Overview
Defines a connection to an SFTP server. Store the connection JSON in the connections/ directory.
Connection File: connections/sftp-server.json
JSON
{
"name": "sftpServer",
"type": "sftp",
"url": "{{sftp.host}}",
"port": 22,
"username": "{{sftp.username}}",
"password": "{{sftp.password}}",
"remoteDirectory": "{{sftp.remoteDirectory}}"
}
Properties in config/application.properties (or PlatformManager environment variables):
sftp.host=sftp.example.com
sftp.username=im-user
sftp.password=secret
sftp.remoteDirectory=/upload/pricefx
Using the Connection in Routes
Reference by connection name in the SFTP URI:
XML
<routes xmlns="http://camel.apache.org/schema/spring">
<route id="exportToSftp">
<from uri="timer://trigger?repeatCount=1"/>
<to uri="pfx-api:fetch?objectType=PX&filter=exportFilter"/>
<to uri="pfx-csv:marshal"/>
<to uri="pfx-sftp:upload?connection=sftpServer&fileName={{sftp.path}}/export_${date:now:yyyyMMdd}.csv"/>
</route>
</routes>
Common Pitfalls
-
Never hardcode credentials — always use
{{property}}placeholders -
The
namefield in the JSON must match theconnection=parameter in the route URI -
remoteDirectorymust exist on the SFTP server before the route runs -
For key-based authentication, use
privateKeyFileandprivateKeyPassphraseinstead ofpassword