On Monday, July 16, 2018 at 12:18:44 PM UTC-7, [email protected] wrote: > > I need to upload an image in a post REST service > and process the uploaded image for further processing. > > Though I can read the filename, size or 'type' of the file but not able to > get the content of the same. > by using request.vars > > request.vars.my_image > > > > I want to utilize the file by either reading the content as the stream the > send it directly or can save it locally and then read in normally. >
Normally, unless you've set up the front end to do otherwise, the request body for a POST isn't yet "officially" a file. You can access it with a couple lines like data = request.body.read() filedata = cStringIO.StringIO(data) request.body is discussed at <URL:http://web2py.com/books/default/chapter/29/04/the-core#request> /dps and then u > > I tried even > > with open('img.jpg', 'w+') as the_file: > the_file.write(request.vars.image1) > > but ended up with > TypeError: expected a character buffer object > > Please help > -- 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.

