Skip to content

Instantly share code, notes, and snippets.

@wthorp
Created August 14, 2023 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wthorp/b6239e521fe3f82ce4dd3a308192c067 to your computer and use it in GitHub Desktop.
Save wthorp/b6239e521fe3f82ce4dd3a308192c067 to your computer and use it in GitHub Desktop.
Presigned GET Python
import boto3
ACCESS_KEY = "..."
SECRET_KEY = "..."
BUCKET_NAME = "..."
PATH_WITHIN_BUCKET = "example/path"
EXPIRES = 3600 # seconds
URL = "https://gateway.storjshare.io"
session = boto3.session.Session()
s3 = session.client(service_name="s3", aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET_KEY, endpoint_url=URL)
url = s3.generate_presigned_url('get_object', Params={"Bucket":BUCKET_NAME, "Key":PATH_WITHIN_BUCKET}, ExpiresIn=EXPIRES)
print(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment