I am writing a server in python using Flask. And I know I am going to receive a request that it's type is multipart. These are the requests headers I receive from the post request:
Transfer-Encoding: chunked
Content-Length:
X-Data-Length: 8010
Host: ******
Content-Type: multipart/form-data; boundary=********
*This is how I receive the request:
@app.route('/***', methods == ['POST'])
def some_function():
print request.headers
mp_data = decoder.MultipartDecoder.from_response(request)
for part in multipart_data.parts:
print(part.content)
print(part.headers)
How am I supposed to retrieve the file sent to me in that request? I have tried using request-toolbelt MultipartDecoder but got lost trying to do so.
Any help solving this would be appreciated.
- The code was taken from this answer: https://stackoverflow.com/a/33370069/10306617