I am facing the issue with google signed URL expiry time. I want to signed URL expire in 5 seconds but its not expiring. here is my python code:
from datetime import datetime,timezone
expiration_time = datetime.now(timezone.utc) + timedelta(seconds=5)
bucket = client.get_bucket(settings.GS_BUCKET_NAME)
blob = bucket.blob(object_name)
signed_url = blob.generate_signed_url(expiration=expiration_time)
Even I have tried with this code as well getting same issue
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(blob_name)
url = blob.generate_signed_url(
version="v4",
# This URL is valid for 15 minutes
expiration=datetime.timedelta(seconds=5),
# Allow GET requests using this URL.
method="GET",
)
print("Generated GET signed URL:")
print(url)
print("You can use this URL with any user agent, for example:")
print(f"curl '{url}'")
return url
Thanks in advance
New contributor
techno test is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.