Hello,
I am trying to use CURL to upload a file in the 'upload' field using REST
services. But on using the command, some garbage is getting uploaded, even
though it shows as type "file" but I could not download the file (invalid
request) and the URL becomes too lengthy (looks like the file contents are
uploaded)
Models
db.define_table('test', Field('date', 'datetime'),
Field('user'),
Field('upload_data','upload'))
Controllers
@request.restful()
def api():
response.view = 'generic.json'
def GET(tablename, id):
if not tablename == 'test':
raise HTTP(400)
return dict(record = db.test(id))
def POST(tablename, **fields):
if not tablename == 'test':
raise HTTP(400)
return db.test.validate_and_insert(**fields)
return locals()
CURL syntax
curl POST -i -F [email protected] http:
//<servername>:8000/testapp/default/api/test.json
Has anyone used the CURL to upload a file (zip file) with web2py?
--
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.