"""Connector for AWS S3.""" import boto3 def create_presigned_url(bucket: str, key: str, expiration: int = 30) -> str: """Generate a temporary presigned url. Args: bucket (str): Name of s3 bucket. key (str): Name of existing s3 object key. expiration (int): Number of seconds the url is valid. Defaults to 30 seconds. Returns: str: Presigned url. """ client = boto3.client('s3') return client.generate_presigned_url( ClientMethod='get_object', ExpiresIn=expiration, Params={ 'Bucket': bucket, 'Key': key }, )