Hi everyone, this is something that has been asked several times and still there's no specific solution.
I need to upload files by using a Rest API, so far I know we have nice ways to implement our apps in web2py http://www.web2pyslices.com/slice/show/1533/restful-api-with-web2py is one way, simple and clean. the other one is http://experts4solutions.com/collection2/default/examples both work perfectly fine wiith regular form data, as it comes with uploads they dont. following the recipe from Bruno I can upload files by using curl like this curl POST -F "name=myfile" -F "image=@/home/user/myimgfile.png" http://127.0.0.1:8000/myapp/services/api/uploadimg and it works. In this new project I need to upload several images and some other format files (csv, doc, pdf, xls), as now I'm working with Vue.js and Axios it would be awesome (and somehow faster) applying it. when I try to send the request using axios in this way let img=e.target.files; let formData = new FormData(); formData.append('file', img[0]); axios.post('../services/api/uploadimg',{ name:'test from axios', image:formData }, { headers: { 'Content-Type': 'multipart/form-data' } }) .then((response)=>{console.log('file uploaded');}) .catch((error)=>{console.log(error);}); } server returns an error Traceback (most recent call last): File "/home/user/web2py/gluon/restricted.py", line 219, in restricted exec(ccode, environment) File "/home/user/web2py/applications/myapp/controllers/services.py", line 50, in <module> File "/home/user/web2py/gluon/globals.py", line 414, in <lambda> self._caller = lambda f: f() File "/home/user/web2py/gluon/globals.py", line 377, in f res = rest_action(*request.args, **request.vars) File "/home/user/web2py/gluon/globals.py", line 309, in vars self.parse_all_vars() File "/home/user/web2py/gluon/globals.py", line 280, in parse_all_vars for key, value in iteritems(self.post_vars): File "/home/user/web2py/gluon/globals.py", line 301, in post_vars self.parse_post_vars() File "/home/user/web2py/gluon/globals.py", line 237, in parse_post_vars dpost = cgi.FieldStorage(fp=body, environ=env, keep_blank_values=1) File "/usr/lib/python2.7/cgi.py", line 507, in __init__ self.read_multi(environ, keep_blank_values, strict_parsing) File "/usr/lib/python2.7/cgi.py", line 621, in read_multi raise ValueError, 'Invalid boundary in multipart form: %r' % (ib,) ValueError: Invalid boundary in multipart form: ' couln't find much on that error but an old post in this group from 2012 https://groups.google.com/forum/#!topic/web2py/ixeUUWryZh0/discussion Any suggestions?, meanwhile I'm still trying to make it work. Greets. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.