Last active
April 14, 2022 20:41
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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