[MERGE] [FIX] mail: make the detection of Content-Type based on filename instead of only offering 'application/octet-stream'. This allows to have a better detection of the software to use by the browser. opw 606233

bzr revid: mat@openerp.com-20140429090446-6691y6h9vdkbbnuu
This commit is contained in:
Martin Trigaux 2014-04-29 11:04:46 +02:00
commit 9806fd4225
1 changed files with 3 additions and 1 deletions

View File

@ -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()