FTPFileTransmitOperator

使用 FTPFileTransmitOperator 來取得或放置檔案到/從 FTP 伺服器。

使用運算子

關於參數定義,請查看 FTPFileTransmitOperator

以下範例展示如何使用 FTPFileTransmitOperator 將本機儲存的檔案傳輸到遠端 FTP 伺服器

tests/system/ftp/example_ftp.py[原始碼]

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,
)

以下範例展示如何使用 FTPFileTransmitOperator 從遠端 FTP 伺服器拉取檔案。

tests/system/ftp/example_ftp.py[原始碼]

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

使用 FTPSFileTransmitOperator 來取得或放置檔案到/從 FTPS 伺服器。

使用運算子

關於參數定義,請查看 FTPSFileTransmitOperator

以下範例展示如何使用 FTPSFileTransmitOperator 將本機儲存的檔案傳輸到遠端 FTPS 伺服器

tests/system/ftp/example_ftp.py[原始碼]

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,
)

以下範例展示如何使用 FTPSFileTransmitOperator 從遠端 FTPS 伺服器拉取檔案。

tests/system/ftp/example_ftp.py[原始碼]

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,
)

這篇文章對您有幫助嗎?