title: Parse multipart request string in Python
body: <p>I have a string like this</p>
  
  <pre><code>"--5b34210d81fb44c5a0fdc1a1e5ce42c3\r\nContent-Disposition: form-data; name=\"author\"\r\n\r\nJohn Smith\r\n--5b34210d81fb44c5a0fdc1a1e5ce42c3\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--5b34210d81fb44c5a0fdc1a1e5ce42c3--\r\n"
  </code></pre>
  
  <p>I also have request headers available in other vairbles.</p>
  
  <p>How do I easily parse this with Python3?</p>
  
  <p>I am handling a file upload in AWS Lambda via API Gateway, request body and headers are available via Python dicts.</p>
  
  <p>There are other similar questions on stackoverflow, but most are assuming use of the <code>requests</code> module or other modules and expect the request details to be in a specific object or format.</p>
  
  <p>NOTE: I am aware its possible to have user upload to S3 and trigger Lambda, but I am intentionally choosing not to do that in this case.</p>