{"id":1326,"library":"apache-airflow-providers-ftp","title":"Apache Airflow FTP Provider","description":"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.","status":"active","version":"3.14.2","language":"en","source_language":"en","source_url":"https://github.com/apache/airflow/tree/main/airflow/providers/ftp","tags":["Airflow","FTP","FTPS","Provider","DAG","ETL","File Transfer"],"install":[{"cmd":"pip install apache-airflow-providers-ftp","lang":"bash","label":"Install FTP Provider"}],"dependencies":[{"reason":"This is an Airflow provider and requires Apache Airflow to run.","package":"apache-airflow","optional":false}],"imports":[{"symbol":"FTPOperator","correct":"from apache_airflow_providers_ftp.operators.ftp import FTPOperator"},{"symbol":"FTPHook","correct":"from apache_airflow_providers_ftp.hooks.ftp import FTPHook"},{"symbol":"FTPSFileTransferOperator","correct":"from apache_airflow_providers_ftp.operators.ftps import FTPSFileTransferOperator"},{"symbol":"FTPSHook","correct":"from apache_airflow_providers_ftp.hooks.ftps import FTPSHook"}],"quickstart":{"code":"from __future__ import annotations\n\nimport pendulum\n\nfrom airflow.decorators import dag\nfrom airflow.operators.bash import BashOperator\nfrom apache_airflow_providers_ftp.operators.ftp import FTPOperator\n\n# Ensure you have an FTP connection configured in Airflow UI (Admin -> Connections)\n# with conn_id='ftp_default'.\n# Set: Conn Id = ftp_default, Conn Type = FTP\n# Host: your_ftp_host (e.g., 'localhost' or 'ftp.example.com')\n# Port: 21 (or 22 for SFTP if using an SFTP provider, 990 for implicit FTPS)\n# Login: your_username\n# Password: your_password\n\n@dag(\n    dag_id=\"ftp_example_dag\",\n    start_date=pendulum.datetime(2023, 10, 26, tz=\"UTC\"),\n    catchup=False,\n    schedule=None,\n    tags=[\"ftp\", \"example\", \"provider\"],\n)\ndef ftp_dag():\n    # Create a dummy local file to upload\n    create_local_file = BashOperator(\n        task_id=\"create_local_file\",\n        bash_command=\"echo 'Hello from Airflow FTP provider!' > /tmp/airflow_ftp_test.txt\"\n    )\n\n    # Upload the file to FTP\n    upload_file_to_ftp = FTPOperator(\n        task_id=\"upload_file_to_ftp\",\n        ftp_conn_id=\"ftp_default\",\n        local_filepath=\"/tmp/airflow_ftp_test.txt\",\n        remote_filepath=\"/remote_airflow_test.txt\",\n        operation=\"put\", # 'put' (upload), 'get' (download), 'delete' (delete remote)\n        create_intermediate_dirs=True,\n    )\n\n    # Clean up the local dummy file\n    clean_local_file = BashOperator(\n        task_id=\"clean_local_file\",\n        bash_command=\"rm /tmp/airflow_ftp_test.txt\"\n    )\n\n    create_local_file >> upload_file_to_ftp >> clean_local_file\n\nftp_dag()\n","lang":"python","description":"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."},"warnings":[{"fix":"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.","message":"Incorrect Airflow connection configuration for FTP/FTPS. Users often use a generic 'HTTP' or 'SFTP' connection type, or fail to set the 'Conn Type' to 'FTP' for FTP/FTPS operations.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"Distinction between FTP and FTPS, and explicit vs. implicit FTPS. The `FTPOperator` and `FTPHook` default to FTP. For FTPS, you must use `FTPSFileTransferOperator` or `FTPSHook` and configure the connection accordingly.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"File transfer mode (binary vs. ASCII). Issues can arise when transferring text files in binary mode, or vice versa, especially across different operating systems with varying line endings.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"Large file transfers may encounter network timeouts, leading to task failures. The default FTP connection timeout might be too short for very large files or slow networks.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}