The File Transfer Protocol (FTP) is a standard communication protocol used for the transfer of computer files from a server to a client. The SSH File Transfer Protocol (SFTP) is similar but operates over SSH for added security.
The Weble universal gateway FTP driver acts as an FTP/SFTP client that connects to a remote file server. It maps the remote file system to gateway addresses, allowing files and directories to be browsed, uploaded, downloaded, created, and deleted directly from the gateway interface. File metadata (size, timestamps, type) is automatically retrieved and exposed as address properties.
The driver is useful for:
A common use case is to combine the FTP driver with the CSV driver: the CSV driver generates data export files, and the FTP driver uploads them to a remote server for collection or archival.
Create a new gateway and select the FTP driver. Configure the connection to the remote FTP or SFTP server:
ftp (port 21) or sftp (port 22, recommended for security).22: when you select the ftp protocol, change it to 21 yourself.root./).Once the gateway is started, it connects to the remote server and lists the contents of the configured base directory. The root directory address %ftp is automatically created.
To explore the file system, right-click on a directory and select Read directory to list its contents. Each file and directory discovered is created as a gateway address in a tree structure. You can also select Read directory recursive to list all contents including subdirectories.
All file operations are accessible via the right-click context menu on addresses:
| Action | Description |
|---|---|
| Read directory | Lists the immediate contents of the directory. |
| Read directory recursive | Lists all contents including all subdirectories. |
| Create file | Creates a new empty file in the directory (prompts for file name). |
| Create directory | Creates a new subdirectory (prompts for directory name). |
| Remove dir. | Removes an empty directory. |
| Remove dir. recursive | Removes a directory and all its contents. |
| Download zip | Downloads, as a ZIP archive, the files of the directory that are already listed as addresses. Run Read directory recursive first to include everything. |
| Upload zip | Uploads and extracts a ZIP archive into the directory. |
| Upload file | Uploads a single file into the directory. |
| Refresh | Refreshes the file metadata (size, timestamps). |
| Action | Description |
|---|---|
| Remove file | Deletes the file from the remote server. |
| Download | Downloads the file to your computer. |
| Upload | Uploads a replacement file (overwrites the existing file). |
| Refresh | Refreshes the file metadata. |
| Label | JSON Key | Description |
|---|---|---|
| Name | name | A descriptive name for this FTP gateway instance. |
| Cluster ID | cluster | 0 (default): the gateway runs in its own process. Any other number: the gateway shares one process with the gateways that have the same number. See Gateway clusters. |
| Description | description | Optional description for this gateway. |
| Protocol | protocol | Transfer protocol: ftp (standard FTP, port 21) or sftp (SSH File Transfer Protocol, port 22). SFTP is recommended for secure transfers. Default: sftp. |
| Host | host | IP address or domain name of the remote FTP/SFTP server. Default: localhost. |
| Port | port | TCP port of the remote server. Default: 22 (SFTP). Use 21 for standard FTP. |
| Username | user | Username for authentication on the remote server. |
| Password | pwd | Password for authentication on the remote server. |
| Directory | basedir | Initial remote directory to browse. Default: /. All addresses will be relative to this base directory. |
| Connection State | connectionManagement | Connection persistence mode: Keeps it open (maintains a permanent connection to the server) or Opens it when needed (connects only when a file operation is requested, then disconnects after a short idle period). Default: Keeps it open. |
Keep this gateway on Cluster ID
0: the driver restarts its process when the connection fails, which would restart every gateway of a shared cluster.
SFTP connection:
{
"protocol": "sftp",
"host": "192.168.1.50",
"port": 22,
"user": "datauser",
"pwd": "securePassword",
"basedir": "/home/datauser/exports",
"connectionManagement": "Keeps it open"
}
FTP connection with on-demand connection:
{
"protocol": "ftp",
"host": "ftp.example.com",
"port": 21,
"user": "ftpuser",
"pwd": "ftpPassword",
"basedir": "/",
"connectionManagement": "Opens it when needed"
}
FTP addresses use the prefix %ftp followed by the file or directory path:
%ftp — the root directory (base directory configured on the gateway)%ftp/data — a subdirectory named "data"%ftp/data/report.csv — a file in the "data" subdirectory%ftp/logs/2024/january.log — nested pathThe address tree mirrors the remote file system structure. Directories and files are distinguished by their type metadata (d for directory, - for file).
A special address %ftp_logs is automatically created to receive the result of every command, read, write and transfer (see section 5). Connection events only go to the driver log.
The following parameters are available on each address. They can be edited directly in the grid columns:
| Column | JSON Key | Description |
|---|---|---|
| Insert | insert | Directories only. Controls automatic discovery of directory contents: manual (contents listed only via right-click), children (automatically lists immediate children), or descendents (automatically lists all nested contents recursively). |
| Delete | delete | Controls what happens when a file is deleted on the remote server: manual (address remains, marked as deleted) or auto (address is automatically removed from the gateway). |
| Del. old files | deleteOldFiles | Set it on a directory. Maximum age of the files it contains (in milliseconds). Each time the directory is refreshed (automatic refresh, or Refresh in the context menu; Read directory does not purge), a file whose modification time is older than this duration is deleted on the remote server and its address is removed, but only if the Delete parameter of that file is auto. Leave empty to disable. |
| Refresh | refresh | manual (refresh only on request) or auto: the driver re-reads the address by itself (the listing for a directory, the content preview for a file) when the gateway connects or the address is saved, then every Polling milliseconds. With auto and no polling interval, the address is only refreshed at these moments. |
| Polling | polling | Polling interval in milliseconds for automatic refresh. Only effective when Refresh is not set to manual. |
| Log | log | Logging mode: never, on update, always, or a duration in milliseconds. |
Addresses created by a directory listing inherit Delete and Refresh from their parent directory (and Insert when it is descendents).
Each address stores file metadata in the json.meta property, visible in the grid columns:
| Column | Description |
|---|---|
| Type | Directory or File. |
| Size | File size in bytes (displayed in human-readable format). |
| AccessTime | Last access timestamp. |
| ModifyTime | Last modification timestamp. |
The AccessTime and ModifyTime columns are hidden by default; show them from the column menu of the grid.
Reading a file address retrieves a preview of the file content (limited to ~1500 bytes by default). Reading a directory address retrieves the directory listing and updates the child addresses.
Writing to an FTP address:
cmd property runs a command (table below);read only), and an unknown command returns invalid command.| Command | Target | Description |
|---|---|---|
ls |
Directory | Lists the directory contents (one level). |
ls -r |
Directory | Lists the directory contents recursively. |
mkdir "name" |
Directory | Creates a subdirectory with the given name. |
touch "name" |
Directory | Creates an empty file with the given name. |
rmdir |
Directory | Removes an empty directory. |
rm -r |
Directory | Removes a directory and all its contents recursively. |
rm |
File | Deletes the file. |
mv <new path> |
File or directory | Renames or moves it. The new path is relative to the gateway base directory, e.g. {"cmd":"mv archive/report_old.csv"}. |
cat |
File | Re-reads the content preview of the file. |
These commands are used internally by the context menu actions but can also be triggered programmatically via routes.
There is no Rename entry in the context menu: to rename a file, type the command in its Value cell, e.g. {"cmd":"mv data/new_name.csv"}.
To upload the files produced by the CSV driver, use its Transfer CSV files button, which creates the routes for you.
Files can be uploaded and downloaded through the gateway streaming API (see Streaming for authentication and examples). In a URL, the % of the address is written %25:
GET /peers/gateways/<id>/streaming?address=%25ftp/path/file.txt&fileName=file.txtPOST /peers/gateways/<id>/streaming?address=%25ftp/path/file.txt&options={"override":1}| Option | Effect |
|---|---|
override |
Required to replace an existing file; without it the upload is refused with file exists. |
zip |
On a directory: download it as a ZIP archive, or upload a ZIP archive to be extracted into it. Without zip, a directory is transferred as a TAR stream. |
Only one transfer at a time is accepted per address (busy otherwise).
When Connection State is set to Keeps it open, the driver maintains a permanent connection to the FTP/SFTP server. This is the fastest mode for frequent file operations but uses a persistent network connection.
If the connection is lost, the driver will automatically attempt to reconnect.
When set to Opens it when needed, the driver connects only when a file operation is requested (directory listing, file read, upload, etc.). After a short idle period (~5 seconds with no pending operations), the connection is closed.
This mode is useful when connecting to servers that limit concurrent connections or when file operations are infrequent.
%ftp_logs shows the result of every command, read, write and transfer. A successful upload ends with ul stream on "%ftp/dir/file.csv" bytes: 1234 finished (2 s), a failed one with ended with error "<reason>". Connection and reconnection messages are in the driver log.file exists: the destination file already exists and the transfer was not allowed to overwrite it.preview›; use Download to get the whole file. The limit can be changed with the maxFileSize key of the gateway JSON.missing license in the driver log: the FTP driver is a licensed option.