Skip to content

Commit 2336630

Browse files
authored
Add cacheControl field to google cloud storage (#31338)
* add cache control parameter * consistency
1 parent ba3665f commit 2336630

File tree

1 file changed

+5
-0
lines changed
  • airflow/providers/google/cloud/hooks

1 file changed

+5
-0
lines changed

airflow/providers/google/cloud/hooks/gcs.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ def upload(
461461
timeout: int | None = DEFAULT_TIMEOUT,
462462
num_max_attempts: int = 1,
463463
metadata: dict | None = None,
464+
cache_control: str | None = None,
464465
) -> None:
465466
"""
466467
Uploads a local file or file data as string or bytes to Google Cloud Storage.
@@ -476,6 +477,7 @@ def upload(
476477
:param timeout: Request timeout in seconds.
477478
:param num_max_attempts: Number of attempts to try to upload the file.
478479
:param metadata: The metadata to be uploaded with the file.
480+
:param cache_control: Cache-Control metadata field.
479481
"""
480482

481483
def _call_with_retry(f: Callable[[], None]) -> None:
@@ -512,6 +514,9 @@ def _call_with_retry(f: Callable[[], None]) -> None:
512514
if metadata:
513515
blob.metadata = metadata
514516

517+
if cache_control:
518+
blob.cacheControl = cache_control
519+
515520
if filename and data:
516521
raise ValueError(
517522
"'filename' and 'data' parameter provided. Please "

0 commit comments

Comments
 (0)