SFTP Download
SFTP Download
Section titled “SFTP Download”Type: sftp-download · Package: SFTP Activities v1.1.0 · Output: string
Downloads a file from the SFTP server to the robot’s machine. To collect files an external system leaves on the server: bank reports, vendor data, exchange files.
How it works
Section titled “How it works”Copies the file at remotePath (server) to localPath (robot’s machine, including the name) and returns the local path:
- Missing local folders are created.
- If the local file already exists, it is replaced completely by the downloaded one. Since version 1.1.0 (before, if the previous file was larger, its trailing bytes remained).
- The download is first written to a temporary file in the same folder and renamed when it finishes: if it fails (for example, the remote file does not exist), the file that was at
localPathstays intact and no partial file is left. - The remote file is not modified: to archive it use SFTP Move / Rename.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
remotePath | string | — | Path of the remote file to download. |
localPath | string | — | Local destination path, with the file name. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanSftpSession | — | Session from SFTP Connect. Inherited inside a body. |
Output
Section titled “Output”Returns a string with the local path of the downloaded file (the same value as localPath).
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'remotePath' is required. / 'localPath' is required. | The parameter is missing or the expression returned null. |
'session' must be a ZoanSftpSession. | The activity is outside the SFTP Connect body and received no session. |
| Server error: file not found | remotePath does not exist. Check it first with SFTP Exists or take paths from SFTP List Directory. |
| Local path access error | The robot cannot write to localPath, or the file is open in another program. |
Example
Section titled “Example”Download all CSV files of a remote folder and archive them on the server:
SFTP Connect host = "sftp.vendor.com" username = "zoan" password = credential("sftp-vendor")["password"] └─ body: SFTP List Directory remotePath = "/outbound" pattern = "*.csv" → output: files For Each items = files itemVariable = item └─ activities: SFTP Download remotePath = item["fullName"] localPath = pathJoin("C:/downloads", item["name"]) → output: localFile Read CSV path = localFile → output: data SFTP Move / Rename sourcePath = item["fullName"] destinationPath = "/outbound/processed/" + item["name"]Related activities
Section titled “Related activities”- SFTP List Directory — find out which files are available to download.
- SFTP Upload — the reverse operation.