Skip to content

Commit

Permalink
Merge pull request #28 from umccr/hotfix/add-disposition-params-for-s…
Browse files Browse the repository at this point in the history
…3-presign-url-api

Hotfix/add disposition params for s3 presign url api
  • Loading branch information
raylrui authored Jul 11, 2024
2 parents e26b290 + b22c926 commit c37f2ee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions libumccr/aws/libs3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name="libumccr",
version="0.4.0rc3",
version="0.4.0rc4",
author="UMCCR and Contributors",
author_email="[email protected]",
description="UMCCR Reusable Python modules",
Expand Down

0 comments on commit c37f2ee

Please sign in to comment.