[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
This commit is contained in:
parent
001a034e58
commit
d9423585d5
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue