diff options
author | Patrick Maia <patrickjourdanmaia@gmail.com> | 2014-11-12 16:39:21 +0000 |
---|---|---|
committer | Patrick Maia <patrickjourdanmaia@gmail.com> | 2014-11-12 16:39:43 +0000 |
commit | fa24aaf94af1dd8b4ead48d6518d3770a60d1211 (patch) | |
tree | 85fcc33ecb4b3b5f1a33fb286669a38d73b5de4b /service | |
parent | 077c8abf47abb10c5c1dc92ab5c3a36d353281ec (diff) |
Card #30 - fixes bug that was preventing attachment download
Diffstat (limited to 'service')
-rw-r--r-- | service/pixelated/controllers/attachments_controller.py | 8 | ||||
-rw-r--r-- | service/test/support/integration_helper.py | 2 |
2 files changed, 5 insertions, 5 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) diff --git a/service/test/support/integration_helper.py b/service/test/support/integration_helper.py index 36d297d6..0411abea 100644 --- a/service/test/support/integration_helper.py +++ b/service/test/support/integration_helper.py @@ -186,7 +186,7 @@ class SoledadTestBase: def get_attachment(self, ident, encoding): request = requestMock(path='/attachment/' + ident) request.args = { - 'encoding': encoding + 'encoding': [encoding] } _render(self.resource, request) return request.getWrittenData() |