Manually uploading a file from FieldStorage

37 views
Skip to first unread message

Lou C

unread,
Jan 14, 2016, 9:44:53 PM1/14/16
to web2py-users
Hey, I am trying to manually upload a file from a request without using SQLFORMS, as this is is done through a REST client. This is is what I have so far:

id = db.image.insert(file = db.image.file.store(request.vars.profile_pic.file,request.vars.profile_pic.filename))

This works, but fails to upload the BLOB, and only uploads the filename? Calling the link generated, only downloads an empty file.
I also have tried this

stream = open(request.vars.profile_pic.file.read(),'rb')
id = db.image.insert(file = db.image.file.store(stream,request.vars.profile_pic.filename))

This gives the error of argument 1 must be encoded string without NULL bytes, not str

By the way, my application is running on GAE, and my client is a mobile application that sends the data through HTTP request.
Reply all
Reply to author
Forward
0 new messages