The `apache-airflow-providers-ftp` package provides operators and hooks to interact with FTP and FTPS servers within Apache Airflow DAGs. It enables tasks like uploading, downloading, and deleting files from remote FTP/FTPS locations. The current version is 3.14.2, and provider packages release independently from core Airflow, typically for bug fixes, new features, or compatibility with new Airflow versions.
pip install apache-airflow-providers-ftpVerified import paths — ran on the pinned version, not inferred.
This quickstart defines an Airflow DAG that demonstrates uploading a file to an FTP server using the `FTPOperator`. It first creates a local dummy file, then uploads it to the configured FTP server, and finally cleans up the local file. Remember to configure an 'FTP' type connection in the Airflow UI with `conn_id='ftp_default'` and appropriate host, login, and password.
In Airflow UI (Admin -> Connections), create a connection with 'Conn Type' explicitly set to 'FTP'. Ensure 'Host', 'Port', 'Login', and 'Password' fields are correctly filled. For FTPS, specify parameters like `explicit_ftp` and `ssl_context_kw` in the 'Extra' field as JSON.
For FTPS, use `FTPSFileTransferOperator` or `FTPSHook`. Configure the Airflow connection's 'Extra' field with JSON parameters like `{"explicit_ftp": true}` for explicit FTPS, or specific `ssl_context_kw` for advanced SSL settings. The port for FTPS is typically 21 for explicit or 990 for implicit.The `FTPOperator` and `FTPSFileTransferOperator` have a `transfer_mode` parameter (default is 'binary'). Explicitly set `transfer_mode='ascii'` when dealing with plain text files to ensure correct line ending handling during transfer.
Consider implementing retries for your Airflow tasks. For longer timeouts, you might need to specify a `timeout` parameter when initializing the Hook (e.g., `FTPHook(ftp_conn_id, timeout=300)`). If not directly exposed by the operator, you might need to extend the hook or pass it via the 'Extra' field of the Airflow connection if supported by the underlying library.
Install the provider package using pip: `pip install apache-airflow-providers-ftp`. If you're using a containerized Airflow setup (e.g., Docker, Kubernetes), ensure this command is included in your `Dockerfile` or entrypoint script to install the provider into the Airflow environment.
Ensure the `apache-airflow-providers-ftp` package is installed in your Airflow environment using `pip install apache-airflow-providers-ftp`. Verify that the import statement `from apache_airflow_providers_ftp.operators.ftp import FTPOperator` (or similar) is correct and matches the installed package structure.