Skip to content

Commit

Permalink
Merge pull request #705 from umccr/fix/add-content-disposition-for-s3…
Browse files Browse the repository at this point in the history
…-presign-api

add content disposition header for s3 presign api
  • Loading branch information
raylrui authored Jul 11, 2024
2 parents 746bf41 + 00d0ab0 commit 995ac4c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion data_portal/viewsets/s3object.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def get_queryset(self):
@action(detail=True)
def presign(self, request, pk=None):
obj: S3Object = self.get_object()
return _presign_response(obj.bucket, obj.key)
content_disposition = request.headers.get('Content-Disposition', 'attachment')
return _presign_response(obj.bucket, obj.key, content_disposition)

@action(detail=True)
def status(self, request, pk=None):
Expand Down
4 changes: 2 additions & 2 deletions data_portal/viewsets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def _error_response(message, status_code=400, err=None) -> Response:
)


def _presign_response(bucket, key) -> Response:
response = libs3.presign_s3_file(bucket, key)
def _presign_response(bucket, key, content_disposition) -> Response:
response = libs3.presign_s3_file(bucket, key, content_disposition)
if response[0]:
return Response({'signed_url': response[1]})
else:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ python-dateutil==2.9.0.post0
google-auth==2.30.0
Werkzeug==3.0.3
libica==2.4.0
libumccr==0.3.0
libumccr==0.4.0rc4
gspread==5.12.4
gspread-pandas==3.3.0
sample-sheet==0.13.0
Expand Down

0 comments on commit 995ac4c

Please sign in to comment.