Skip to content

Commit

Permalink
Merge pull request #149 from HE-Arc/fix-filename
Browse files Browse the repository at this point in the history
Fixes sample download extension
  • Loading branch information
qtipee authored Jul 24, 2020
2 parents 6f82932 + 4b5455f commit e0e0c8b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/safm_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ def get(self, request, sample_id, download):
with open(path_to_file, 'rb') as f:
mime_type = mimetypes.MimeTypes().guess_type(sample.file.name)
response = HttpResponse(f, content_type=mime_type)
filename = sample.name
ext = sample.file.name.split('.')[-1]
filename = '{0}.{1}'.format(sample.name, ext)
response['Content-Disposition'] = f'attachement; filename="{filename}"'
response['Access-Control-Expose-Headers'] = 'Content-Disposition' # To allow the client to read it

Expand Down

0 comments on commit e0e0c8b

Please sign in to comment.