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 儲存桶。

請注意,您可以透過將共享雲端硬碟的 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_name, object_name, folder_id, file_name, drive_id, impersonation_chain 引數使用Jinja 模板,從而動態確定引數值。

參考

欲瞭解更多資訊,請參閱:

此條目有幫助嗎?