ftp_list
Lists files on a remove ftp server. Must be used inside {% ftp_session %}
{% endftp_session %}
.
Accepts:
path
- path to the directory on remote ftp
Result is saved in a variable that follows as keyword.
Result has following format:
{
"ok": true,
"error": null, // null only when ok: true
"files": [{
"name": "test.csv",
"type": "file" // or "dir",
"size": 1000,
"modifiedAt": 1758557578 // unix
}]
}
Below code will list and log all files in /external
directory on a remote ftp and logs file name.
{% assign host = "ftp.com" %}
{% assign user = "[email protected]" %}
{% assign password = "password123" %}
{% assign port = 21 %}
{% ftp_session host:host, user:user, password:password, port:port, sftp:false %}
{% ftp_list path:"/external" as list_result %}
{% if list_result.ok %}
{% for el in list_result.files %}
{% if el.type == "file" %}
{% log el.name %}
{% endif %}
{% endfor %}
{% endif %}
{% endftp_session %}
Last updated