diff options
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/controllers/attachments_controller.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/service/pixelated/controllers/attachments_controller.py b/service/pixelated/controllers/attachments_controller.py index 4965f166..d6d2f5e7 100644 --- a/service/pixelated/controllers/attachments_controller.py +++ b/service/pixelated/controllers/attachments_controller.py @@ -16,7 +16,6 @@ import io import re - from twisted.protocols.basic import FileSender from twisted.python.log import err @@ -27,11 +26,12 @@ class AttachmentsController: self.querier = querier def attachment(self, request, attachment_id): - encoding = request.args.get('encoding') + encoding = request.args.get('encoding', [None])[0] + filename = request.args.get('filename', [attachment_id])[0] attachment = self.querier.attachment(attachment_id, encoding) - content_type = self._extract_mimetype(attachment['content-type']) - request.setHeader('Content-Type', content_type) + request.setHeader(b'Content-Type', b'application/force-download') + request.setHeader(b'Content-Disposition', bytes('attachment; filename=' + filename)) bytes_io = io.BytesIO(attachment['content']) d = FileSender().beginFileTransfer(bytes_io, request) |