Reputation: 377
I am trying to get the value of a POST with multipart/form-data
to my backend.
files = {
'image': ('youtried.jpg', (open('youtried.jpg', 'rb')), 'image/jpg', {'Expires': '0'}),
'name': 'Deojeff'
}
r = requests.post('http://localhost/service/images', files=files)
print (r.text)
def on_post(self, req, resp):
"""Creates an image."""
x = req.stream.read()
base64.b64encode(x)
helpers.write_json(resp, falcon.HTTP_200, {
'name': str(x)
})
How to get the value of 'name' ( in this case the value is 'Deojeff' ) in the on_post method of my class?
Upvotes: 0
Views: 3346
Reputation: 31
Try:
req.get_param('name')
returns the value of the param 'name'. Use req.params()
to get the list of all the params with values.
Upvotes: 1