Generates a v4 signed URL for downloading a blob.
Note that this method requires a service account key file. You cannot use
this if you are using Application Default Credentials from Google Compute
Engine or from the Google Cloud SDK.
Source code in pygsuite/images/uploader.py
| def generate_download_signed_url_v4(bucket, blob_name: str, timeout: int = 15):
"""Generates a v4 signed URL for downloading a blob.
Note that this method requires a service account key file. You cannot use
this if you are using Application Default Credentials from Google Compute
Engine or from the Google Cloud SDK.
"""
blob = bucket.blob(blob_name)
url = blob.generate_signed_url(
version="v4",
# This URL is valid for 15 minutes
expiration=datetime.timedelta(minutes=timeout),
# Allow GET requests using this URL.
method="GET",
)
return url
|