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 模板,从而动态确定参数值。

参考

欲了解更多信息,请参阅:

此条目有帮助吗?