Skip to content

SFTP Functions: sftphandler

The SFTP functions enable automation workflows to interact with an SFTP (Secure File Transfer Protocol) server. They support operations such as creating a connection, downloading and uploading files, monitoring directories, creating directories, and closing the connection.

Prerequisites:

  • SFTP Server Credentials: Ensure you have the server IP, port, username, and password.

Available Commands:

  1. Create Connection (createConnection): Establishes a connection to the SFTP server.
  2. Download (download): Retrieves files from the SFTP server to a local directory.
  3. Upload (upload): Sends files from a local directory to the SFTP server.
  4. Watch (watch): Monitors a specified directory on the SFTP server for files with a particular extension.
  5. Create Directory (createDirectory): Creates a new directory on the SFTP server.
  6. Close Connection (closeConnection): Terminates the connection to the SFTP server.

Steps to Configure Each Command:

  1. Create Connection (createConnection)

Establish a connection to the SFTP server.

    • Action: Select Set a Variable Value from the Action dropdown.
    • Element Key: Enter a variable name to store the connection status (e.g., SFTPConnectionStatus).
    • Parameters:
      • Cmd: Select createConnection.
      • ServerIP: Enter the SFTP server’s IP address (e.g., 123.456.7.89).
      • Port: Enter the port number (default is 22).
      • UserName: Enter your SFTP username (e.g., sftp_user).
      • Password: Enter your SFTP password (e.g., P@ssword123).
scrn-sftp-create-connection-tabular-view
Tabular View
scrn-sftp-create-connection-card-view
Card View
    • Outcome: Returns true if the connection is successful; otherwise, returns false.
  1. Download (download)

Download files from the SFTP server.

    • Action: Select Set a Variable Value from the Action
      dropdown.
    • Element Key: Enter a variable name to store the download status (e.g., DownloadStatus).
    • Parameters:
      • Cmd: Select download.
      • destination: Specify the path of the file on the SFTP server (e.g.,
        /remote/folder/file.txt).
      • source: Specify the local directory path where the file will be saved (e.g.,
        C:LocalFolderfile.txt).
scrn-sftp-download-tabular-view
Tabular View
scrn-sftp-download-card-view
Card View
    • Outcome: Returns true if the download is successful; otherwise, returns
      false.
  1. Upload (upload)

Upload files to the SFTP server.

    • Action: Select Set a Variable Value from the Action
      dropdown.
    • Element Key: Enter a variable name to store the upload status (e.g., UploadStatus).
    • Parameters:
      • Cmd: Select upload.
      • destination: Specify the destination path on the SFTP server (e.g.,
        /remote/folder/uploaded_file.txt).
      • source: Specify the local file path to be uploaded (e.g., C:LocalFolderfile.txt).
scrn-sftp-upload-tabular-view
Tabular View
scrn-sftp-upload-card-view
Card View
    • Outcome: Returns true if the upload is successful; otherwise, returns
      false.
  1. Watch (watch):

Monitor a directory on the SFTP server for files with a specific extension.

    • Action: Select Set a Variable Value from the Action dropdown.
      dropdown.
    • Element Key: Enter a variable name to store the path of the detected file (e.g.,
      WatchedFilePath).
    • Parameters:
      • Cmd: Select watch.
      • remotePath: Specify the directory path on the SFTP server to monitor (e.g.,
        /remote/logs/).
      • extension: Specify the file extension to watch for (e.g., .txt).
      • prefix: (Optional) Specify a filename prefix to filter.
      • timeout: (Optional) Set the duration (in seconds) to wait for a file to appear.
      • orderBy: (Optional) Specify the order criterion (e.g., dateTime).
      • sortBy: (Optional) Specify the sort order (asc for ascending, desc for descending).
scrn-sftp-watch-tabular-view
Tabular View
scrn-sftp-watch-card-view
Card View
    • Outcome: Returns the path of the detected file if found within the timeout period; otherwise,
      returns null.
  1. Create Directory (createDirectory)

Create a new directory on the SFTP server.

    • Action: Select Set a Variable Value from the Action
      dropdown.
    • Element Key: Enter a variable name to store the operation status (e.g.,
      DirectoryCreationStatus).
    • Parameters:
      • Cmd: Select createDirectory.
      • directoryPath: Specify the path of the new directory to be created on the SFTP server
        (e.g., /remote/new_folder/).
scrn-sftp-create-directory-tabular-view
Tabular View
scrn-sftp-create-directory-card-view
Card View
    • Outcome: Returns true if the directory is successfully created; otherwise,
      returns false.
  1. Close Connection (closeConnection)

Terminate the connection to the SFTP server.

    • Action: Select Set a Variable Value from the Action
      dropdown.
    • Element Key: Enter a variable name to store the disconnection status (e.g.,
      DisconnectionStatus).
    • Parameters:
      • Cmd: Select closeConnection.
scrn-sftp-close-connection-tabular-view
Tabular View
scrn-sftp-close-connection-card-view
Card View
    • Outcome: Returns true if the connection is successfully closed; otherwise,
      returns false.

Back To Top