airflow.providers.google.cloud.transfers.gcs_to_local

Module Contents

class airflow.providers.google.cloud.transfers.gcs_to_local.GCSToLocalFilesystemOperator(*, bucket: str, object_name: Optional[str] = None, filename: Optional[str] = None, store_to_xcom_key: Optional[str] = None, gcp_conn_id: str = 'google_cloud_default', google_cloud_storage_conn_id: Optional[str] = None, delegate_to: Optional[str] = None, impersonation_chain: Optional[Union[str, Sequence[str]]] = None, **kwargs)[source]

Bases: airflow.models.BaseOperator

Downloads a file from Google Cloud Storage.

If a filename is supplied, it writes the file to the specified location, alternatively one can set the store_to_xcom_key parameter to True push the file content into xcom. When the file size exceeds the maximum size for xcom it is recommended to write to a file.

See also

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

Parameters
  • bucket (str) – The Google Cloud Storage bucket where the object is. Must not contain ‘gs://’ prefix. (templated)

  • object_name (str) – The name of the object to download in the Google cloud storage bucket. (templated)

  • filename (str) – The file path, including filename, on the local file system (where the operator is being executed) that the file should be downloaded to. (templated) If no filename passed, the downloaded data will not be stored on the local file system.

  • store_to_xcom_key (str) – If this param is set, the operator will push the contents of the downloaded file to XCom with the key set in this parameter. If not set, the downloaded data will not be pushed to XCom. (templated)

  • gcp_conn_id (str) – (Optional) The connection ID used to connect to Google Cloud.

  • google_cloud_storage_conn_id (str) – (Deprecated) The connection ID used to connect to Google Cloud This parameter has been deprecated. You should pass the gcp_conn_id parameter instead.

  • delegate_to (str) – 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 (Union[str, Sequence[str]]) – 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 (templated).

template_fields = ['bucket', 'object_name', 'filename', 'store_to_xcom_key', 'impersonation_chain'][source]
ui_color = #f0eee4[source]
execute(self, context)[source]

Was this entry helpful?