ftp
Set of utilities helping you to access, download, move or delete files in FTP or sFTP server.
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