FTP Sink
Provided by: "Apache Software Foundation"
Support Level for this Kamelet is: "Stable"
Uploads each message as a file to a directory on an FTP server.
Use it to deliver exports, reports or data files to a partner or a legacy system that receives files over FTP. For an encrypted connection use ftps-sink, and for a server you reach with SSH use sftp-sink.
Input: the body is the content of the file, as text, bytes or a stream. The name of the file comes from the file header, or from ce-file when file is not set; any directory in it is dropped, so reports/data.csv is written as data.csv. Without these headers, CamelFileName is used as it is, subdirectories included, and without any of them a unique name is generated.
Output: the message is unchanged. The CamelFileNameProduced header is set to the path of the file on the server.
Good to know: a file with the same name is replaced, unless fileExist says otherwise. A file is uploaded under its real name from the start, so a reader that polls the directory can pick it up half-written. To prevent that, set tempPrefix to upload it under a temporary name and rename it once it is complete, or doneFileName to write an empty done file next to it once it is complete. The connection and the login are not encrypted. A file name that points outside directoryName fails the message. Files are sent in ASCII (text) mode unless binary is true. Headers that start with CamelFile or CamelOverruleFile, except CamelFileName, are removed from the message first, so they cannot change what the Kamelet does.
Configuration Options
The following table summarizes the configuration options available for the ftp-sink Kamelet:
| Property | Name | Description | Type | Default | Example |
|---|---|---|---|---|---|
Connection Host | Required The host name or IP address of the FTP server, without | string | ftp.example.com | ||
Connection Port | Required The port of the FTP server. FTP servers usually listen on port 21. | string | 21 | ||
Directory Name | Required The directory on the server to write the files to. A path without a leading | string | upload/orders | ||
Password | Required The password of | string | |||
Username | Required The user to log in to the FTP server as. | string | |||
Autocreate Missing Directories | If true, | boolean | true | ||
Binary Mode | If true, files are transferred in binary mode, byte for byte. When false, they are transferred in ASCII mode, which is meant for text. Set it to true for files that are not text, such as images, archives or PDF files. | boolean | false | ||
Done File Name | The name of an empty file to write next to each file once the file is complete, so that a reader knows the file can be read. | string | ${file:name}.done | ||
If File Exists | What to do when a file with the same name is already in the directory. Enum values: * Override * Append * Fail * Ignore | string | Override | ||
Passive Mode | If true, the transfers use passive mode, in which the integration opens all the connections to the server. Set it to true when the integration or the server is behind a firewall or NAT, where the default active mode often fails. | boolean | false | ||
Temporary Name Prefix | A prefix for the name a file is uploaded under. Once the upload is complete, the file is renamed to its real name, so a reader that skips the names with this prefix never picks up a half-written file. | string | .tmp- |
Dependencies
At runtime, the ftp-sink Kamelet relies upon the presence of the following dependencies:
-
camel:ftp
-
camel:kamelet
Camel JBang usage
Prerequisites
-
You’ve installed JBang.
-
You have executed the following command:
jbang app install camel@apache/camel Supposing you have a file named route.yaml with this content:
- route:
from:
uri: "kamelet:timer-source"
parameters:
period: 10000
message: 'test'
steps:
- to:
uri: "kamelet:ftp-sink" You can now run it directly through the following command
camel run route.yaml FTP Sink Kamelet Description
Connection Configuration
Requires: - Connection host (FTP server hostname) - Connection port (defaults to 21) - Username and password credentials - Directory name for file operations
File Transfer Options
-
Transfer Mode: ASCII (default) or Binary mode
-
Passive Mode: Can be enabled for firewall compatibility
-
File Existence Handling: Override (default), Append, Fail, or Ignore
-
Auto-create Directories: Automatically creates missing directories (enabled by default)
-
Temporary Name Prefix: Upload each file under a temporary name, such as
.tmp-orders.csv, and rename it to its real name once it is complete (not set by default) -
Done File Name: Write an empty done file next to each file once it is complete, such as
orders.csv.done(not set by default)
Optional Headers
In the header, you can optionally set the file / ce-file property to specify the name of the file to upload.
If you do not set the property in the header, the Kamelet uses a default naming convention.
The value is reduced to a single file name before use: any directory component is dropped, so reports/2026/data.csv is stored as data.csv. The file is always written inside the configured directory.
Example with a Temporary Name and a Done File
By default a file is uploaded under its real name from the start, so a reader that polls the directory can pick it up half-written. Set tempPrefix, doneFileName, or both, to prevent that:
- route:
from:
uri: "timer:tick"
parameters:
period: 60000
steps:
- setBody:
constant: "order-1,42"
- setHeader:
name: file
constant: "orders.csv"
- to:
uri: "kamelet:ftp-sink"
parameters:
connectionHost: "ftp.example.com"
username: "ftpuser"
password: "ftppass"
directoryName: "/incoming"
tempPrefix: ".tmp-"
doneFileName: "${file:name}.done" Each file is uploaded as .tmp-orders.csv and renamed to orders.csv once the upload is complete, and then an empty orders.csv.done is written next to it. The FTP Source Kamelet, like other readers built with Camel, skips the names that start with a dot, so it never reads a half-written file; another reader can wait for the .done file. In doneFileName, ${file:name} stands for the name of the file and ${file:name.noext} for the name without its extension; no other ${…} is allowed. The user needs the right to rename files on the server. tempPrefix cannot be combined with fileExist set to Append, and with Override a file of the same name is deleted when the upload starts.