Google Drive 至 Google Cloud Storage 傳輸運算子

Google 有兩項服務用於儲存資料。Google Cloud Storage 用於儲存來自各種應用程式的大型資料。Google Drive 用於儲存日常使用資料,包括文件和相片。Google Cloud Storage 與 Google Cloud 服務有強大的整合。Google Drive 內建機制以促進群組工作,例如文件編輯器、檔案共享機制。

先決條件任務

若要使用這些運算子,您必須執行幾項操作

運算子

Google Storage 和 Google Drive 之間的檔案傳輸是使用 GoogleDriveToGCSOperator 運算子執行。

複製單一檔案

以下運算子將單一檔案從共用 Google Drive 資料夾複製到 Google Cloud Storage Bucket。

請注意,您可以透過將共用雲端硬碟的 ID 傳遞給 folder_iddrive_id 參數,從共用雲端硬碟的根資料夾傳輸檔案。

tests/system/google/cloud/gcs/example_gdrive_to_gcs.py[原始碼]

upload_gdrive_to_gcs = GoogleDriveToGCSOperator(
    task_id="upload_gdrive_object_to_gcs",
    gcp_conn_id=CONNECTION_ID,
    folder_id=FOLDER_ID,
    file_name=DRIVE_FILE_NAME,
    bucket_name=BUCKET_NAME,
    object_name=OBJECT,
)

您可以搭配 bucket_nameobject_namefolder_idfile_namedrive_idimpersonation_chain 參數使用 Jinja 模板,讓您動態決定值。

參考

如需更多資訊,請參閱

此條目是否有幫助?