Created
January 21, 2024 02:15
-
-
Save amcclosky/b7a4b857944ddf414b2ed2b6726648c0 to your computer and use it in GitHub Desktop.
R2 Compatible boto3 s3 client
This file contains hidden or 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
import boto3 | |
from botocore.config import Config | |
from . import config | |
r2 = boto3.client( | |
service_name="s3", | |
endpoint_url=config.R2_S3_ENDPOINT, | |
aws_access_key_id=config.R2_ACCESS_KEY_ID, | |
aws_secret_access_key=config.R2_SECRET_ACCESS_KEY, | |
config=Config(signature_version="s3v4"), # this is necessary so that generated pre-signed urls are r2 compatible | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment