Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add content disposition header for s3 presign api #705

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion data_portal/viewsets/s3object.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,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