Skip to content

Commit

Permalink
Add cacheControl field to google cloud storage (#31338)
Browse files Browse the repository at this point in the history
* add cache control parameter

* consistency
  • Loading branch information
ying-w committed Jun 8, 2023
1 parent ba3665f commit 2336630
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions airflow/providers/google/cloud/hooks/gcs.py
Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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 "
Expand Down

0 comments on commit 2336630

Please sign in to comment.