Downloadfromsftp¶
flowtask.components.DownloadFromSFTP
¶
DownloadFromSFTP
¶
Bases: SSHClient, DownloadFromBase
DownloadFromSFTP.
Overview
Download a file or directory from an SFTP server using the functionality from DownloadFrom.
Properties (inherited from DownloadFromBase and SSHClient)
.. table:: Properties :widths: auto
+--------------------+----------+-----------+----------------------------------------------------------------------------+
| Name | Required | Summary |
+--------------------+----------+-----------+----------------------------------------------------------------------------+
| credentials | Yes | Credentials to establish connection with SFTP server (username and password) |
+--------------------+----------+-----------+----------------------------------------------------------------------------+
| host | Yes | The hostname or IP address of the SFTP server. |
+--------------------+----------+-----------+----------------------------------------------------------------------------+
| port | No | The port number of the SFTP server (default: 22). |
+--------------------+----------+-----------+----------------------------------------------------------------------------+
| tunnel | No | Dictionary defining a tunnel to use for the connection. |
+--------------------+----------+-----------+----------------------------------------------------------------------------+
| block_size | No | Block size for file transfer (default: 4096 bytes). |
+--------------------+----------+-----------+----------------------------------------------------------------------------+
| max_requests | No | Maximum number of concurrent file transfers (default: 5). |
+--------------------+----------+-----------+----------------------------------------------------------------------------+
| create_destination | No | Boolean flag indicating whether to create the destination directory |
| | | if it doesn't exist (default: True). |
+--------------------+----------+-----------+----------------------------------------------------------------------------+
| source | Yes | A dictionary specifying the source file or directory on the SFTP server. |
| | | Can include: |
| | | whole_dir (Optional, bool): Whether to download the entire directory (default: False).|
| | | recursive (Optional, bool): Whether to download subdirectories recursively when |
| | | `whole_dir` is True (default: False). |
+--------------------+----------+-----------+----------------------------------------------------------------------------+
| filename | No | The filename to download from the SFTP server (if not using `source`). |
+--------------------+----------+-----------+----------------------------------------------------------------------------+
| mdate | No | Modification date of the file to download (for filtering based on modification time). |
+--------------------+----------+-----------------------+----------------------------------------------------------------+
| rename | No | A new filename to use for the downloaded file. |
+--------------------+----------+-----------+----------------------------------------------------------------------------+
| masks | No | A dictionary mapping mask strings to replacement strings used for renaming files and |
| | | modification dates. |
+--------------------+----------+-----------+----------------------------------------------------------------------------+
| overwrite | No | Whether to overwrite existing files in the destination directory (default: False). |
+--------------------+----------+-----------+----------------------------------------------------------------------------+
| remove | No | Whether to remove the downloaded files from the SFTP server after |
| | | successful download (default: False). |
+--------------------+----------+-----------+----------------------------------------------------------------------------+
Save the downloaded files on the new destination.
Example:
```yaml
DownloadFromSFTP:
file:
pattern: Performance_Tracker/*
mdate: '{today}'
host: altice_ltm_sftp_host
port: altice_ltm_sftp_port
credentials:
username: altice_ltm_sftp_username
password: altice_ltm_sftp_password
known_hosts: null
directory: /home/ubuntu/altice/files/
overwrite: true
masks:
'{today}':
- yesterday
- mask: '%Y-%m-%d'
```