ftp

Set of utilities helping you to access, download, move or delete files in FTP or sFTP server.

By default when an error is encountered in any of the ftp operations - a critical error is thrown and script terminates the execution. You can set the parameter exitOnError to false to continue executing the script anytime a FTP error is detected.

Download

{% json ftp_params %}
  {
    "mode": "download",
    "host": "ftp.com",
    "user": "[email protected]",
    "password": "pass123",
    "path": "/",
    "port": 21,
    "fileName": "ftp_file.csv",
    "file": "local_file.csv",
    "exitOnError": false
  }
{% endjson %}

{% assign result = ftp_params | ftp %}

Above snippet downloads remove file called ftp_file.csv and saves it in your storage as local_file.csv.

Next you can access this file by adding following commands:

Your csv_parsed variable would now contain an array of object with csv columns as property names.

List

Gets all files from remote ftp server. You can next use for loop to iterate over available files.

Above snippet would log all files on FTP server under directory specified in path parameter.

Move

Moves file ftp_file.csv from / to /processed/

Delete

Deletes file ftp_file.csv from / directory.

Upload

Uploads file with defined content to ftp. File is saved as sample_upload.txt

sFTP servers

To access sFTP servers additional paramter sftp set to true is expected. To list files on sFTP server following snippet could be used.

Last updated