FTP task

Note: Each FTP task execution triggers an API call in the back-end. These API calls are deducted from your overall external calls limit that is provided for your Creator plan. Here, the system counts the number of actual executions, and not the number of times the task appears in the script.

Overview

The File Transfer Protocol (FTP) task in Deluge allows you to access and modify:

  • files on an FTP server using upload and download operations.
  • file data stored externally and bring it into your Zoho service.

Note:

  • You can use this task to download files up to 5 MB.
  • This task is currently not applicable in Zoho Flow.

Syntax

response = ftp
[
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 after the operation.
<action_type>TEXTThe type of action that is to be performed in the server:

Allowed Values:
upload
download
<host_name>TEXTThe domain name of the FTP server.
<port_number>
(Optional)
NUMBERThe value of the port of the server to be mentioned.
Default port number: 21
<path_value>TEXTThe URL path of the service that needs to be accessed, excluding the base URL.
For example, "/myftpserver.example.com".
The path is necessary, especially for download actions.

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)
TEXTThe file object to be uploaded. This is mandatory for upload.
<connection_name>
(optional)
TEXTThe connection name configured to access the FTP server.

Use Case

An organization maintains a set of standard reference files, such as compliance checklists, policy documents, or default templates, which are periodically updated and made available from a public URL. These files need to be uploaded to a centralized FTP server so that downstream systems and users can access them through a controlled location.

// Log initial step
info "FTP"; info "****"; // Fetch a text file from a public web URL ftpTxtFile = invokeurl [ url : "https://sample-files.com/downloads/documents/txt/simple.txt" type : GET ]; // Convert the content to a file object ftpTxtFile = ftpTxtFile.toFile("ftp.txt"); info ftpTxtFile; // Upload the file to the FTP server uploadFtp = ftp [ action : upload host : "ftp.examplehost.com" port : 21 path : "" files : ftpTxtFile connection : "ftp_connection" ]; info uploadFtp; // Download the same file from the FTP server downloadFtp = ftp [ action : download host : "ftp.examplehost.com" port : 21 path : "/ftp.txt" connection : "ftp_connection" ]; info downloadFtp; // Log the content of the downloaded file info downloadFtp.getFileContent();

Examples

Example 1: Upload File to FTP Server   

The below script uploads a file to the FTP server.

// Upload file to FTP server
uploadFtp = ftp
[
action : upload
host : "ftp.examplehost.com"
port : 21
path : "/home/uploads/"
files : textFile
connection : "ftp_connection"
];
info uploadFtp;

Example 2: Download File from an FTP Server

The below script download a file from the FTP server.    

// Download file from FTP server
downloadFtp = ftp
[
action : download
host : "ftp.examplehost.com"
port : 21
path : "/home/uploads/example.png"
connection : "ftp_connection"
];
info downloadFtp;

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
          226
         }

Related Links