I have the following simple AWS Chalice route:
@app.route('/submit', methods=['POST'],
content_types=['multipart/form-data'])
def submit():
request_info = app.current_request.raw_body
return request_info
I then use a simple form with multipart data, including a docx file upload:
<form enctype="multipart/form-data" method="POST" action="http://localhost:8000/submit">
<input name='foo' type="text">
<br>
<input name="bar" type="file">
<br>
<button type='submit'>
Submit
</button>
</form>
The raw_body
attribute of the request is just the bytes of the http request, and I'm looking for a pre-existing Python library that will let me extract each form field and also write the bytes of the docx file to disk (in this case a tmp folder in AWS Lambda). Is there a library that will take raw_body
as an argument and allow me to parse the individual fields so that I don't have to write such a parser myself? Trying to google for this is difficult, since most of the results that come back all have to do with using python to consume web APIs, which is not what I want.