summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/pixelated/controllers/attachments_controller.py8
-rw-r--r--service/test/support/integration_helper.py2
-rw-r--r--web-ui/app/templates/mails/full_view.hbs2
3 files changed, 6 insertions, 6 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()
diff --git a/web-ui/app/templates/mails/full_view.hbs b/web-ui/app/templates/mails/full_view.hbs
index 46a55318..4cdf25b9 100644
--- a/web-ui/app/templates/mails/full_view.hbs
+++ b/web-ui/app/templates/mails/full_view.hbs
@@ -73,7 +73,7 @@
<ul>
{{#each attachments }}
<li>
- <a href="/attachment/{{ this.ident }}?encoding={{ this.encoding }}" target="_blank">{{ this.name }}</a>
+ <a href="/attachment/{{ this.ident }}?encoding={{ this.encoding }}&filename={{ this.name }}">{{ this.name }}</a>
</li>
{{/each }}
</ul>