airflow.providers.ftp.operators.ftp
¶
This module contains FTP operator.
Module Contents¶
Classes¶
Operation that can be used with FTP. |
|
FTPFileTransmitOperator for transferring files from remote host to local or vice a versa. |
|
FTPSFileTransmitOperator for transferring files from remote host to local or vice a versa. |
- class airflow.providers.ftp.operators.ftp.FTPOperation[source]¶
Operation that can be used with FTP.
- class airflow.providers.ftp.operators.ftp.FTPFileTransmitOperator(*, ftp_conn_id='ftp_default', local_filepath, remote_filepath, operation=FTPOperation.PUT, create_intermediate_dirs=False, **kwargs)[source]¶
Bases:
airflow.models.BaseOperator
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
- Parameters
ftp_conn_id (str) – ftp connection id from airflow Connections.
local_filepath (str | list[str]) – local file path to get or put. (templated)
remote_filepath (str | list[str]) – remote file path to get or put. (templated)
operation (str) – specify operation ‘get’ or ‘put’, defaults to put
create_intermediate_dirs (bool) –
create 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 creatingtmp
,``tmp1`` andtmp2
if they don’t exist. If thecreate_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, )
- execute(context)[source]¶
Derive when creating an operator.
Context is the same dictionary used as when rendering jinja templates.
Refer to get_template_context for more context.
- get_openlineage_facets_on_start()[source]¶
Return OpenLineage datasets.
- Dataset will have the following structure:
input: file://hostname/path output file://<conn.host>:<conn.port>/path.
- class airflow.providers.ftp.operators.ftp.FTPSFileTransmitOperator(*, ftp_conn_id='ftp_default', local_filepath, remote_filepath, operation=FTPOperation.PUT, create_intermediate_dirs=False, **kwargs)[source]¶
Bases:
FTPFileTransmitOperator
FTPSFileTransmitOperator for transferring files from remote host to local or vice a versa.
This operator uses an FTPSHook to open ftps 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: FTPSFileTransmitOperator