airflow.providers.google.suite.transfers.local_to_drive

此檔案包含 Google 雲端硬碟運算子。

模組內容

類別

LocalFilesystemToGoogleDriveOperator

將檔案列表上傳到 Google 雲端硬碟資料夾。

class airflow.providers.google.suite.transfers.local_to_drive.LocalFilesystemToGoogleDriveOperator(local_paths, drive_folder, gcp_conn_id='google_cloud_default', delete=False, ignore_if_missing=False, chunk_size=100 * 1024 * 1024, resumable=False, impersonation_chain=None, folder_id='root', show_full_target_path=True, **kwargs)[原始碼]

基底類別:airflow.models.BaseOperator

將檔案列表上傳到 Google 雲端硬碟資料夾。

此運算子將本機檔案列表上傳到 Google 雲端硬碟資料夾。本機檔案可以在上傳後選擇性地刪除。

參見

有關如何使用此運算子的更多資訊,請參閱指南:LocalFilesystemToGoogleDriveOperator

參數
  • local_paths (collections.abc.Sequence[pathlib.Path] | collections.abc.Sequence[str]) – 本機檔案路徑的 Python 列表

  • drive_folder (pathlib.Path | str) – 雲端硬碟資料夾的路徑,如果給定 folder_id,則 drive_folder 是該資料夾的子路徑。

  • gcp_conn_id (str) – 用於 GCP 的 Airflow 連線 ID。

  • delete (bool) – 上傳後是否應刪除本機檔案?

  • ignore_if_missing (bool) – 如果為 True,即使某些檔案無法上傳也不會失敗。

  • chunk_size (int) – 檔案將以這麼多位元組的區塊上傳。僅當 resumable 設定為 True 時使用。如果檔案要以單個區塊上傳,請傳入值 -1。請注意,Google App Engine 對請求大小有 5MB 的限制,因此您絕不應將區塊大小設定為大於 5MB,或設定為 -1。

  • resumable (bool) – 如果這是可恢復上傳,則為 True。False 表示在單個請求中上傳。

  • impersonation_chain (str | collections.abc.Sequence[str] | None) – 可選的服務帳戶,用於使用短期憑證模擬,或用於獲取列表中最後一個帳戶的存取權杖所需的帳戶鏈式列表,該帳戶將在請求中被模擬。如果設定為字串,則該帳戶必須授予原始帳戶「服務帳戶權杖建立者」IAM 角色。如果設定為序列,則列表中的身分必須將「服務帳戶權杖建立者」IAM 角色授予緊鄰的前一個身分,列表中的第一個帳戶將此角色授予原始帳戶

  • folder_id (str) – 雲端硬碟資料夾中每個本機路徑的基礎/根資料夾 ID。

  • show_full_target_path (bool) – 如果為 true,則會在日誌中顯示完整的可用檔案路徑。

返回

上傳後的遠端檔案 ID。

template_fields = ('local_paths', 'drive_folder')[原始碼]
execute(context)[原始碼]

在建立運算子時衍生。

上下文與呈現 jinja 範本時使用的字典相同。

有關更多上下文,請參閱 get_template_context。

此條目是否有幫助?