Merge lp:~openerp-dev/openobject-addons/7.0-opw-606233-jas into lp:openobject-addons/7.0

Proposed by Anaël Closson (openerp)
Status: Merged
Merged at revision: 10022
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-606233-jas
Merge into: lp:openobject-addons/7.0
Diff against target: 22 lines (+3/-1)
1 file modified
mail/controllers/main.py (+3/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-606233-jas
Reviewer Review Type Date Requested Status
Martin Trigaux (OpenERP) (community) Approve
Anaël Closson (openerp) Pending
OpenERP Core Team Pending
Review via email: mp+215607@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jamin Shah(OpenERP) (jamin-openerp) wrote :

Hello,

Fixed the issue of wrong Mime type, used python mimetypes module to detect proper mimetype of the file.

Demo: Go to chatter or wall and try to download different types of file, some browser will popup to open file in application say for example Firefox, it popup and based on your file mimetype it gives you application to openwith, currently we passed application/octet-stream, so Firefox suggests wrong applicatio to openwith.

Used mimetypes and guess mimetype based on filename.

Thanks.

Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

LGTM, thanks

revno: 10022 [merge]
revision-id: <email address hidden>

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mail/controllers/main.py'
2--- mail/controllers/main.py 2012-12-11 14:53:43 +0000
3+++ mail/controllers/main.py 2014-04-14 07:40:29 +0000
4@@ -1,6 +1,7 @@
5 import base64
6 import openerp.addons.web.http as oeweb
7 from openerp.addons.web.controllers.main import content_disposition
8+import mimetypes
9
10 #----------------------------------------------------------
11 # Controller
12@@ -15,8 +16,9 @@
13 if res:
14 filecontent = base64.b64decode(res.get('base64'))
15 filename = res.get('filename')
16+ content_type = mimetypes.guess_type(filename)
17 if filecontent and filename:
18 return req.make_response(filecontent,
19- headers=[('Content-Type', 'application/octet-stream'),
20+ headers=[('Content-Type', content_type[0] or 'application/octet-stream'),
21 ('Content-Disposition', content_disposition(filename, req))])
22 return req.not_found()