decode multipart 2fform data python

Solutions on MaxInterview for decode multipart 2fform data python by the best coders in the world

showing results for - "decode multipart 2fform data python"
Paco
12 Sep 2019
1from requests_toolbelt.multipart import decoder
2
3multipart_string = b"--ce560532019a77d83195f9e9873e16a1\r\nContent-Disposition: form-data; name=\"author\"\r\n\r\nJohn Smith\r\n--ce560532019a77d83195f9e9873e16a1\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example2.txt\"\r\nContent-Type: text/plain\r\nExpires: 0\r\n\r\nHello World\r\n--ce560532019a77d83195f9e9873e16a1--\r\n"
4content_type = "multipart/form-data; boundary=ce560532019a77d83195f9e9873e16a1"
5
6for part in decoder.MultipartDecoder(multipart_string, content_type).parts:
7  print(part.text)
8
9John Smith
10Hello World
11