FTPFileTransmitOperator

FTP

FTPFileTransmitOperator for transferring files from remote host to local or vice a versa. This operator uses an FTPHook to open ftp transport channel that serve as basis for file transfer.

View on GitHub

Last Updated: Jan. 20, 2023

Access Instructions

Install the FTP provider package into your Airflow environment.

Import the module into your DAG file and instantiate it with your desired params.

Parameters

ftp_conn_idftp connection id from airflow Connections.
local_filepathRequiredlocal file path to get or put. (templated)
remote_filepathRequiredremote file path to get or put. (templated)
operationspecify operation ‘get’ or ‘put’, defaults to put
create_intermediate_dirscreate missing intermediate directories when copying from remote to local and vice-versa. Default is False. Example: The following task would copy file.txt to the remote host at /tmp/tmp1/tmp2/ while creating tmp,``tmp1`` and tmp2 if they don’t exist. If the create_intermediate_dirs parameter is not passed it would error as the directory does not exist. put_file = FTPFileTransmitOperator( task_id="test_ftp", ftp_conn_id="ftp_default", local_filepath="/tmp/file.txt", remote_filepath="/tmp/tmp1/tmp2/file.txt", operation="put", create_intermediate_dirs=True, dag=dag )

Documentation

FTPFileTransmitOperator for transferring files from remote host to local or vice a versa. This operator uses an FTPHook to open ftp transport channel that serve as basis for file transfer.

See also

For more information on how to use this operator, take a look at the guide: FTPFileTransmitOperator

Was this page helpful?