Skip to content

Instantly share code, notes, and snippets.

@PandaWhoCodes
Last active April 14, 2022 20:41
Show Gist options
  • Save PandaWhoCodes/29d0b478dc8f0810d6e87af82f33cbbe to your computer and use it in GitHub Desktop.
Save PandaWhoCodes/29d0b478dc8f0810d6e87af82f33cbbe to your computer and use it in GitHub Desktop.
given the name of the file generates a version 3 signed download url for the file
from botocore.client import Config
import boto3
def gen_url(key):
"""
given the name of the file generates a signed download url for the file
:param key: filename in s3
:return: presigned URL that has AWS4-HMAC-SHA256
"""
expTime = 86400
s3 = boto3.resource(
"s3", region_name=REGION, config=Config(signature_version="s3v4")
)
return s3.meta.client.generate_presigned_url(
"get_object", Params={"Bucket": AIRFLOW_BUCKET, "Key": key}, ExpiresIn=expTime
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment