title: Node JS POST multipart/form-data request
body: <p>I want to send files from Node JS through http module using multipart/form-data content-type.
  The problem with binary encoding.
  It's OK when I'm trying to send simple text file:</p>
  
  <pre><code>url: 'some-site.com',
  method: 'POST',
  headers: 
  {
      'content-type': 'multipart/form-data; boundary=-----BNDRY',
      'content-length': 128
  },
  body: '-------BNDRY\r\ncontent-type: text/plain\r\ncontent-disposition: form-data; name="file"; filename="file.txt"\r\n\r\ntest\r\n-------BNDRY--'
  }
  </code></pre>
  
  <p>But when I'm trying to send something like JPG after file reading (e.g. via FS modile) and translate Buffer to string for request body it fails. I've tried different combinations of <strong>Buffer.toString(encoding)</strong> method and <strong>content-transfer-encoding: encoding</strong> header but there was no success. For some reason, base64 encoding doesn't work too, I've tested it with connect bodyParser, and seems like it doesn't care about <strong>content-transfer-encoding: base64</strong> header in body - content still comes as undecoded base64 string.</p>
  
  <p>And I don't want to use external modules like node-formidable or express to solve my problem.</p>
  
  <p>Thanks.</p>