From d9423585d5a28fe007af01d58a1984a3e69883cb Mon Sep 17 00:00:00 2001 From: "Jamin Shah (OpenERP)" Date: Mon, 14 Apr 2014 10:59:04 +0530 Subject: [PATCH] [FIX]Fixed the issue of mimetype not detected properly, used python mimetypes module to detect file's mimitype. bzr revid: jas@tinyerp.com-20140414052904-rp4oia2py6b61xg8 --- addons/mail/controllers/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/mail/controllers/main.py b/addons/mail/controllers/main.py index 4c6f6e56064..e6b0b7cb3c6 100644 --- a/addons/mail/controllers/main.py +++ b/addons/mail/controllers/main.py @@ -1,6 +1,7 @@ import base64 import openerp.addons.web.http as oeweb from openerp.addons.web.controllers.main import content_disposition +import mimetypes #---------------------------------------------------------- # Controller @@ -15,8 +16,9 @@ class MailController(oeweb.Controller): if res: filecontent = base64.b64decode(res.get('base64')) filename = res.get('filename') + content_type = mimetypes.guess_type(filename) if filecontent and filename: return req.make_response(filecontent, - headers=[('Content-Type', 'application/octet-stream'), + headers=[('Content-Type', content_type[0] or 'application/octet-stream'), ('Content-Disposition', content_disposition(filename, req))]) return req.not_found()