From 80ff7155795c0724e5381c13ed482253f14dfabd Mon Sep 17 00:00:00 2001 From: Ray Liu Date: Thu, 11 Jul 2024 09:58:20 +1000 Subject: [PATCH 1/3] add disposition params for s3 presign url api --- libumccr/aws/libs3.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libumccr/aws/libs3.py b/libumccr/aws/libs3.py index 008fcaa..b183cf4 100644 --- a/libumccr/aws/libs3.py +++ b/libumccr/aws/libs3.py @@ -111,7 +111,7 @@ def bucket_exists(bucket) -> bool: return False -def presign_s3_file(bucket: str, key: str) -> (bool, str): +def presign_s3_file(bucket: str, key: str, content_disposition='inline') -> (bool, str): """ Generate a presigned URL https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.generate_presigned_url @@ -122,7 +122,7 @@ def presign_s3_file(bucket: str, key: str) -> (bool, str): :return tuple (bool, str): (true, signed_url) if success, otherwise (false, error message) """ try: - return True, s3_client().generate_presigned_url('get_object', Params={'Bucket': bucket, 'Key': key}) + return True, s3_client().generate_presigned_url('get_object', Params={'Bucket': bucket, 'Key': key, 'ResponseContentDisposition': content_disposition}) except ClientError as e: message = f"Failed to sign the specified S3 object (s3://{bucket}/{key}). Exception - {e}" logger.error(message) From 4ab053fc3e6f8cc9c1e69bbd1ebc9ef46b30bf3d Mon Sep 17 00:00:00 2001 From: Ray Liu Date: Thu, 11 Jul 2024 10:48:07 +1000 Subject: [PATCH 2/3] update the version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a899696..430d83a 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name="libumccr", - version="0.4.0rc3", + version="0.4.0rc4", author="UMCCR and Contributors", author_email="services@umccr.org", description="UMCCR Reusable Python modules", From b22c926c83ba2bf6497011dc5dbef2d3029a658b Mon Sep 17 00:00:00 2001 From: Ray Liu Date: Thu, 11 Jul 2024 11:28:43 +1000 Subject: [PATCH 3/3] add type for content_disposition param --- libumccr/aws/libs3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libumccr/aws/libs3.py b/libumccr/aws/libs3.py index b183cf4..e45d4d5 100644 --- a/libumccr/aws/libs3.py +++ b/libumccr/aws/libs3.py @@ -111,7 +111,7 @@ def bucket_exists(bucket) -> bool: return False -def presign_s3_file(bucket: str, key: str, content_disposition='inline') -> (bool, str): +def presign_s3_file(bucket: str, key: str, content_disposition:str ='inline') -> (bool, str): """ Generate a presigned URL https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.generate_presigned_url