From 233663046d5210359ce9f4db2fe3db4f5c38f6ee Mon Sep 17 00:00:00 2001 From: Ying Date: Thu, 8 Jun 2023 13:51:38 -0700 Subject: [PATCH] Add `cacheControl` field to google cloud storage (#31338) * add cache control parameter * consistency --- airflow/providers/google/cloud/hooks/gcs.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/airflow/providers/google/cloud/hooks/gcs.py b/airflow/providers/google/cloud/hooks/gcs.py index f3cea1567dc2b..6ec22fbc34b5c 100644 --- a/airflow/providers/google/cloud/hooks/gcs.py +++ b/airflow/providers/google/cloud/hooks/gcs.py @@ -461,6 +461,7 @@ def upload( timeout: int | None = DEFAULT_TIMEOUT, num_max_attempts: int = 1, metadata: dict | None = None, + cache_control: str | None = None, ) -> None: """ Uploads a local file or file data as string or bytes to Google Cloud Storage. @@ -476,6 +477,7 @@ def upload( :param timeout: Request timeout in seconds. :param num_max_attempts: Number of attempts to try to upload the file. :param metadata: The metadata to be uploaded with the file. + :param cache_control: Cache-Control metadata field. """ def _call_with_retry(f: Callable[[], None]) -> None: @@ -512,6 +514,9 @@ def _call_with_retry(f: Callable[[], None]) -> None: if metadata: blob.metadata = metadata + if cache_control: + blob.cacheControl = cache_control + if filename and data: raise ValueError( "'filename' and 'data' parameter provided. Please "