Choose where you’d like to start

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
];
ParameterData typeDescription
<response>KEY-VALUE / FILE / TEXT / LISTThe 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. 

Allowed Values:

  • upload
  • download
<host_name>TEXTThe domain name of the remote server.
<port_number>(Optional) NUMBERThe value of the port of the server to be mentioned. 
Default: 22
<path_value>TEXTThe 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.
<file_object>(Optional) TEXTThe name of the file object to be uploaded to the server. This is mandatory for upload.
<connection_name>(Optional) TEXTThe 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
     }

Related Links

Get Started Now

Execute