I am startiing to develop an mobile app for a website using movu.ca ( http://www.menuvegano.com.br), the idea is that the users will be able to post cook recipes and its pictures via the mobile using the api.
For the mobile app I am using tiggzi.com and it is rest based. Everything works, but upload not yet. On Thu, Jun 21, 2012 at 12:42 AM, Massimo Di Pierro < massimo.dipie...@gmail.com> wrote: > The code I posted would not work... It depends on how it is uploaded. > > if you have the code > > curl -X POST \ > -H "Content-Type: text/plain" \ > -T 'hello.txt' \ > http://127.0.0.1:8000/app/default/upload1/hello.txt > > I think you can do > > def upload(): > table = db.tablename > record = db.tablename[request.args(0)]. > > > record.update_record(uploadfield=record.store(file=request.body,filename=request.args(1)) > return 'done' > > > > > On Wednesday, 20 June 2012 18:43:15 UTC-5, rochacbruno wrote: >> >> >> How would it be to receive a file upload thought the restful api? >> >> On Wed, Jun 20, 2012 at 8:39 PM, Massimo Di Pierro < >> massimo.dipie...@gmail.com> wrote: >> >>> You can do >>> >>> @request.restful() >>> >>> >>> def api(): >>> response.view = 'generic.'+request.extension >>> >>> >>> >>> def GET(*args,**vars): >>> >>> >>> >>> patterns = 'auto' >>> parser = db.parse_as_rest(patterns,args****,vars) >>> >>> >>> >>> if parser.status == 200: >>> >>> >>> >>> return dict(content=parser.response) >>> >>> >>> >>> else: >>> raise HTTP(parser.status,parser.erro****r) >>> >>> >>> >>> def POST(table_name,**vars): >>> >>> >>> >>> return db[table_name].validate_and_**in**sert(**vars) >>> >>> def PUT(table_name,record_id,**var**s): >>> >>> return db(db[table_name]._id==record_**id).update(**vars) >>> >>> def PUT(table_name,record_id): >>> >>> return db(db[table_name]._id==record_**id).delete() >>> >>> return locals() >>> >>> >>> On Wednesday, 20 June 2012 11:30:26 UTC-5, Osama Hussain wrote: >>>> >>>> Using the following code web2py generated all possible patterns for all >>>> my tables for GET and POST methods: >>>> >>>> @request.restful() >>>> >>>> >>>> def api(): >>>> response.view = 'generic.'+request.extension >>>> >>>> >>>> >>>> def GET(*args,**vars): >>>> >>>> >>>> patterns = 'auto' >>>> parser = db.parse_as_rest(patterns,args****,vars) >>>> >>>> >>>> >>>> if parser.status == 200: >>>> >>>> >>>> >>>> return dict(content=parser.response) >>>> >>>> >>>> >>>> else: >>>> raise HTTP(parser.status,parser.erro****r) >>>> >>>> >>>> >>>> def POST(table_name,**vars): >>>> >>>> >>>> return db[table_name].validate_and_**in**sert(**vars) >>>> >>>> >>>> >>>> return locals() >>>> >>>> >>>> Is it possible to have patterns generated for PUT and DELETE methods? >>>> >>>> >> -- > --