[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:
commit
9806fd4225
|
@ -1,6 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import openerp.addons.web.http as oeweb
|
import openerp.addons.web.http as oeweb
|
||||||
from openerp.addons.web.controllers.main import content_disposition
|
from openerp.addons.web.controllers.main import content_disposition
|
||||||
|
import mimetypes
|
||||||
|
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
# Controller
|
# Controller
|
||||||
|
@ -15,8 +16,9 @@ class MailController(oeweb.Controller):
|
||||||
if res:
|
if res:
|
||||||
filecontent = base64.b64decode(res.get('base64'))
|
filecontent = base64.b64decode(res.get('base64'))
|
||||||
filename = res.get('filename')
|
filename = res.get('filename')
|
||||||
|
content_type = mimetypes.guess_type(filename)
|
||||||
if filecontent and filename:
|
if filecontent and filename:
|
||||||
return req.make_response(filecontent,
|
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))])
|
('Content-Disposition', content_disposition(filename, req))])
|
||||||
return req.not_found()
|
return req.not_found()
|
||||||
|
|
Loading…
Reference in New Issue