backupdb2/backupdb2/boto.py

19 lines
503 B
Python

import boto3
from botocore.client import Config as BotoConfig
def get_s3(url):
# set up s3 client
s3args = {"config": BotoConfig(signature_version='s3v4')}
endpoint_url = f"{url.scheme}://{url.hostname}"
if url.port:
endpoint_url += f":{url.port}"
s3args["endpoint_url"] = endpoint_url
if url.username and url.password:
s3args["aws_access_key_id"] = url.username
s3args["aws_secret_access_key"] = url.password
return boto3.client('s3', **s3args)