-
-
Save brunomichetti/b2ab59783e013053b31136671aefb258 to your computer and use it in GitHub Desktop.
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
def get_presigned_url_dict_to_upload_file(object_key: str) -> Dict[str, Any]: | |
''' | |
Returns a dict with the necessary data to upload a file for the given key | |
''' | |
session = Session( | |
aws_access_key_id=settings.AWS_ACCESS_KEY_ID, | |
aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY, | |
region_name=settings.AWS_S3_REGION_NAME, | |
) | |
s3client = session.client('s3') | |
url = s3client.generate_presigned_post( | |
Bucket=settings.AWS_STORAGE_BUCKET_NAME, | |
Key=object_key, | |
Fields={ | |
'acl': 'private', | |
}, | |
Conditions=[ | |
{'acl': 'private'}, | |
], | |
ExpiresIn=settings.AWS_PRESIGNED_URL_EXPIRATION_TIME_MINUTES, | |
) | |
return url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment