Reputation: 65
I'm trying to save files sent from C++ code(not by HTML)
But I do not know how to write the script to parse sent data and save it
C++ code works fine(from wireshark captured packet)
from Bottle tutorial: how do I edit it?
category = request.forms.get('category')
upload = request.files.get('upload')
thanks!
update:
I found that request.files
works
files = request.files
for name, fobj in files.iteritems():
fobj.save(some_path)
Upvotes: 2
Views: 552
Reputation: 1
This is what I ended up doing:
from bottle import FileUpload
uploaded_file = FileUpload(request.body, None, filename='some_filename')
uploaded_file.save() # implement conflict resolution here, if needed
Upvotes: 0
Reputation: 6168
If you are just sending the raw file in the HTTP request, access it with request.body
.
http://bottlepy.org/docs/dev/api.html#bottle.BaseRequest.body
Upvotes: 1