My bad, was a typho, still does't work. In another thread read something related to file submission was a functionality of SQLFORM, and I'm using forms with Vue components.
As I said before, params inside formData are correct, and everything is processed ok by the server except files. El 18 feb. 2018 8:41 AM, "Val K" <[email protected]> escribió: > it should be: > var image = event.target.files[0]; //not just `event.target[0]`; > > > > On Sunday, February 18, 2018 at 12:09:46 AM UTC+3, marco mansilla wrote: >> >> Yes, got it. I hace something like: >> >> >> var image = event.target[0]; >> formData.append('name', image.name); >> formData.append('myfile', image); >> axios.post('../services/api/uploads', formData).then(...).catch(...); >> >> Params are correctly passed to the server, but files are not uploaded. >> >> El 16 feb. 2018 22:36, "Val K" <[email protected]> escribió: >> >>> Are you trying to insert formData in something another? I believe, that >>> formData should be passed to axios as is: >>> axios.post('../services/api/uploadimg', formData) >>> >>> if you need to add some fields just do it: >>> formData.append('name', 'blah') >>> >>> >>> >>> >>> On Monday, February 5, 2018 at 7:16:04 AM UTC+3, marco mansilla wrote: >>>> >>>> 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 [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > 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 [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

