title: write base64 to file using stream
body: <p>I am sending a base64 string to my server. On the server I want to create a readable stream that I push the base64 chunks onto that then goes to a writable stream and written to file. My problem is only the first chunk is written to file. My guess is because I create a new buffer with each chunk this is what is causing the problem but if I send just the string chunks in without creating the buffer the image file is corrupt.</p>
  
  <pre><code>var readable = new stream.Readable();
  
  readable._read = function() {}
  
  req.on('data', function(data) {
      var dataText = data.toString();
      var dataMatch = dataText.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/);
      var bufferData = null;
  
      if (dataMatch) {
          bufferData = new Buffer(dataMatch[2], 'base64')
      }
  
      else {
          bufferData = new Buffer(dataText, 'base64')
      }
  
      readable.push(bufferData)
  })
  
  req.on('end', function() {
      readable.push(null);
  })
  </code></pre>