FTPFileTransmitOperator

Use the FTPFileTransmitOperator to get or put files to/from an FTP server.

Using the Operator

For parameter definition take a look at FTPFileTransmitOperator.

The below example shows how to use the FTPFileTransmitOperator to transfer a locally stored file to a remote FTP Server:

tests/system/providers/ftp/example_ftp.py[source]

ftp_put = FTPFileTransmitOperator(
    task_id="test_ftp_put",
    ftp_conn_id="ftp_default",
    local_filepath="/tmp/filepath",
    remote_filepath="/remote_tmp/filepath",
    operation=FTPOperation.PUT,
    create_intermediate_dirs=True,
)

The below example shows how to use the FTPFileTransmitOperator to pull a file from a remote FTP Server.

tests/system/providers/ftp/example_ftp.py[source]

ftp_get = FTPFileTransmitOperator(
    task_id="test_ftp_get",
    ftp_conn_id="ftp_default",
    local_filepath="/tmp/filepath",
    remote_filepath="/remote_tmp/filepath",
    operation=FTPOperation.GET,
    create_intermediate_dirs=True,
)

FTPSFileTransmitOperator

Use the FTPSFileTransmitOperator to get or put files to/from an FTPS server.

Using the Operator

For parameter definition take a look at FTPSFileTransmitOperator.

The below example shows how to use the FTPSFileTransmitOperator to transfer a locally stored file to a remote FTPS Server:

tests/system/providers/ftp/example_ftp.py[source]

ftps_put = FTPSFileTransmitOperator(
    task_id="test_ftps_put",
    ftp_conn_id="ftps_default",
    local_filepath="/tmp/filepath",
    remote_filepath="/remote_tmp/filepath",
    operation=FTPOperation.PUT,
    create_intermediate_dirs=True,
)

The below example shows how to use the FTPSFileTransmitOperator to pull a file from a remote FTPS Server.

tests/system/providers/ftp/example_ftp.py[source]

ftps_get = FTPSFileTransmitOperator(
    task_id="test_ftps_get",
    ftp_conn_id="ftps_default",
    local_filepath="/tmp/filepath",
    remote_filepath="/remote_tmp/filepath",
    operation=FTPOperation.GET,
    create_intermediate_dirs=True,
)

Was this entry helpful?