Merge pull request #2936 from coreos-inc/joseph.schorr/QS-84/content-disposition

Ensure user files are always sent with the Content-Disposition header
This commit is contained in:
josephschorr 2017-12-07 11:42:10 -05:00 committed by GitHub
commit 6c12cb8328
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,7 +30,8 @@ class UserfilesHandlers(View):
file_stream = self._storage.stream_read_file(self._locations, path)
buffered = BufferedReader(file_stream)
file_header_bytes = buffered.peek(1024)
return send_file(buffered, mimetype=self._magic.from_buffer(file_header_bytes))
return send_file(buffered, mimetype=self._magic.from_buffer(file_header_bytes),
as_attachment=True, attachment_filename=file_id)
except IOError:
logger.exception('Error reading user file')
abort(404)