summaryrefslogtreecommitdiff
path: root/addons/web
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2011-09-06 13:53:16 +0200
committerXavier Morel <xmo@openerp.com>2011-09-06 13:53:16 +0200
commitcd78e540a259f488873ea1e8fc30fca07d42d666 (patch)
tree4e7f1913c3c5b12cd98cd67477ddd06110b00f0c /addons/web
parent05513d924bb0f24fa7e40c0246b2cb570a227052 (diff)
[FIX] binary uploading not correctly werkzeugified
bzr revid: xmo@openerp.com-20110906115316-4kybkc2bowpvkhyn
Diffstat (limited to 'addons/web')
-rw-r--r--addons/web/controllers/main.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py
index 6ca5a4f0e35..9e32569c322 100644
--- a/addons/web/controllers/main.py
+++ b/addons/web/controllers/main.py
@@ -1004,7 +1004,7 @@ class Binary(openerpweb.Controller):
('Content-Disposition', 'attachment; filename=' + filename)])
@openerpweb.httprequest
- def upload(self, req, callback, ufile=None):
+ def upload(self, req, callback, ufile):
headers = {}
for key, val in req.httprequest.headers.iteritems():
headers[key.lower()] = val
@@ -1023,14 +1023,15 @@ class Binary(openerpweb.Controller):
});
}
</script>"""
- data = ufile.file.read()
- args = [size, ufile.filename, ufile.headers.getheader('Content-Type'), base64.b64encode(data)]
+ data = ufile.read()
+ args = [ufile.content_length, ufile.filename,
+ ufile.content_type, base64.b64encode(data)]
except Exception, e:
args = [False, e.message]
return out % (simplejson.dumps(callback), simplejson.dumps(args))
@openerpweb.httprequest
- def upload_attachment(self, req, callback, model, id, ufile=None):
+ def upload_attachment(self, req, callback, model, id, ufile):
context = req.session.eval_context(req.context)
Model = req.session.model('ir.attachment')
try:
@@ -1043,7 +1044,7 @@ class Binary(openerpweb.Controller):
</script>"""
attachment_id = Model.create({
'name': ufile.filename,
- 'datas': base64.encodestring(ufile.file.read()),
+ 'datas': base64.encodestring(ufile.read()),
'res_model': model,
'res_id': int(id)
}, context)