airflow.providers.google.suite.transfers.local_to_drive

This file contains Google Drive operators.

Module Contents

Classes

LocalFilesystemToGoogleDriveOperator

Upload a list of files to a Google Drive folder.

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, delegate_to=None, impersonation_chain=None, folder_id='root', show_full_target_path=True, **kwargs)[source]

Bases: airflow.models.BaseOperator

Upload a list of files to a Google Drive folder.

This operator uploads a list of local files to a Google Drive folder. The local files can optionally be deleted after upload.

See also

For more information on how to use this operator, take a look at the guide: LocalFilesystemToGoogleDriveOperator

Parameters
  • local_paths (Sequence[pathlib.Path] | Sequence[str]) – Python list of local file paths

  • drive_folder (pathlib.Path | str) – path of the Drive folder, if folder_id is given, drive_folder is a sub path of the folder.

  • gcp_conn_id (str) – Airflow Connection ID for GCP.

  • delete (bool) – Should the local files be deleted after upload?

  • ignore_if_missing (bool) – If True, don’t fail even if some files can’t be uploaded.

  • chunk_size (int) – File will be uploaded in chunks of this many bytes. Only used when resumable is set to True. Pass in a value of -1 if the file is to be uploaded as a single chunk. Note that Google App Engine has a 5MB limit on request size, so you should never set your chunk size larger than 5MB, or to -1.

  • resumable (bool) – True if this is a resumable upload. False means upload in a single request.

  • delegate_to (str | None) – The account to impersonate using domain-wide delegation of authority, if any. For this to work, the service account making the request must have domain-wide delegation enabled.

  • impersonation_chain (str | Sequence[str] | None) – Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account

  • folder_id (str) – The base/root folder id for each local path in the Drive folder.

  • show_full_target_path (bool) – If true then it reveals full available file path in the logs.

Returns

Remote file ids after upload.

template_fields = ('local_paths', 'drive_folder')[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

Was this entry helpful?