SFTP task
Overview
The SSH File Transfer Protocol (SFTP) task in Deluge allows you to access and modify:
- files on a remote server using upload and download operations.
- file transfers between your Zoho service and external storage.
Note:
- You can use this task to download files up to 5 MB.
- This task is currently not applicable in Zoho Flow.
Syntax
response = SFTP [ action: action_type host: host_name port: port_number path: path_value files: file_name connection: connection_name ];
| Parameter | Data type | Description |
|---|---|---|
| <response> | KEY-VALUE / FILE / TEXT / LIST | The variable that will contain the response returned. Specify if the response is to be performed on the remote server. |
| <action_type> | TEXT | The type of action to be performed in the server.
|
| <host_name> | TEXT | The domain name of the remote server. |
| <port_number> | (Optional) NUMBER | The value of the port of the server to be mentioned. Default: 22 |
| <path_value> | TEXT | The URL path of the service to be accessed, excluding the base URL. For example, "/myftpserver.example.com". The path is necessary, especially for download action.If no path is specified, the root directory will be considered as the destination folder. If a path is specified, then it must start with "/" . |
| <file_object> | (Optional) TEXT | The name of the file object to be uploaded to the server. This is mandatory for upload. |
| <connection_name> | (Optional) TEXT | The connection name configured to access the remote server. |
Use Case
An enterprise manages updated policy documents and procedural templates that are sourced from a public repository. These documents need to be uploaded to a secure SFTP server so internal teams and automated systems can access the latest files from a centralized, trusted location.
// Log initial step info "SFTP"; info "****";
// Download a sample file from a public URL sftpTxtFile = invokeurl [ url : "https://sample-files.com/downloads/documents/txt/simple.txt" type : GET ];
// Convert the text response into a file object sftpTxtFile = sftpTxtFile.toFile("sftp.txt"); info sftpTxtFile;
// Upload the file to a secure SFTP server uploadFtp = sftp [ action : upload host : "sftp.examplehost.com" port : 22 path : "" files : sftpTxtFile connection : "sftp_connection" ]; info uploadFtp;
// Download the same file from the SFTP server downloadFtp = sftp [ action : download host : "sftp.examplehost.com" port : 22 path : "/sftp.txt" connection : "sftp_connection" ]; info downloadFtp;
// Output the content of the downloaded file for validation info downloadFtp.getFileContent();
Examples
Example 1: Upload File to a Remote Server
// Upload a file to SFTP server uploadSftp = sftp [ action : upload host : "sftp.examplehost.com" port : 22 path : "/exports/" files : monthlyreport connection : "sftp_connection" ]; info uploadSftp;
Example 2: Download File from a Remote Server
// Download a file from SFTP server downloadSftp = sftp [ action : download host : "ftp.examplehost.com" port : 22 path : "/home/uploads/example.png" ]; info downloadSftp;
Response Format
The standard response will be returned in the following format:
{
"responseText": "Example.png",
}
- The response for the request to return the response code will be in the following format:
File has been uploaded successfully
200
}
Troubleshooting for SFTP server
1. Host unreachable or connection timeout
These errors occur when Deluge cannot connect to the SFTP server during upload or download file operations.
Check host and port settings
Verify that the SFTP host name and port number are correct (SFTP uses port 22).
Check server accessibility
Confirm that the SFTP server accepts external connections.
If IP restrictions are enabled, request the administrator to whitelist Zoho's outbound IP ranges.
Check connectivity tools
Test the server using an SFTP client such as FileZilla or WinSCP to ensure it is active and reachable.
Check firewall and security rules
Ensure required ports are open and not blocked by firewalls or security tools.
2. Authentication Errors
These errors occur when the server is reachable but login fails.
Validate credentials
Confirm that the username and password match what is configured on the SFTP server.
Check account status
Ensure the SFTP user account is active and permitted to access the target directory.
Check special login restrictions
Ask your server administrator if additional login rules or IP-based constraints apply.
3. File Transfer Errors
These errors happen after login, during upload or download.
Check directory permissions
Verify that the SFTP user has read/write access to the target directory.
Use complete paths
Always provide absolute paths (for example, /home/data/report.txt) instead of relative paths.
Validate folder existence
Ensure all directories referenced in the script already exist on the server.
Check naming and case sensitivity
Confirm the exact file and folder names, especially on Linux servers that enforce case sensitivity.