title: How to save blob as webm on node.js
body: <p>I am recording a video in chrome using <a href="https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RecordRTC" rel="nofollow">RecordRTC.js</a> and then sends the generated blob to node.js server using enctype='multipart/form-data'.</p>
  
  <p>When i send a post request by converting blob as dataURL,</p>
  
  <pre><code>------WebKitFormBoundaryZMbygbTah7gTAgUa
  Content-Disposition: form-data; name="name"
  
  1encof615fpyoj85bzwo.webm
  ------WebKitFormBoundaryZMbygbTah7gTAgUa
  Content-Disposition: form-data; name="type"
  
  video/webm
  ------WebKitFormBoundaryZMbygbTah7gTAgUa
  Content-Disposition: form-data; name="contents"
  
  data:video/webm;base64,GkXfo0AgQoaBAUL3gQFC8oEEQvOBCEKCQAR3ZWJtQoeBA...
  ------WebKitFormBoundaryZMbygbTah7gTAgUa--
  </code></pre>
  
  <p>It Works fine. Except when the data is large, video is not saved properly. Maybe, because whole content might not get transferred due to large size.</p>
  
  <p>So, I tried to send the blob as input type file, but the saved video seems corrupted as it does not play.</p>
  
  <p>The sent blob, when printed on server, is something like this: </p>
  
  <pre><code>Eߣ@ B��B��B��B�B�@webmB��B��S�g�fI�f@(*ױ@B@M�@whammyWA@whammyD�@žT�k@5�@2ׁsŁ��"�...
  </code></pre>
  
  <p>The Server side code is:</p>
  
  <pre><code>function upload(response, file) {
  
     var fileRootName = file.name.split('.').shift(),
       fileExtension = file.name.split('.').pop(),
       filePathBase = upload_dir + '/',
       fileRootNameWithBase = filePathBase + fileRootName,
       filePath = fileRootNameWithBase + '.' + fileExtension,
       fileID = 2,
       fileBuffer;
  
     while (fs.existsSync(filePath)) {
       filePath = fileRootNameWithBase + '(' + fileID + ').' + fileExtension;
       fileID += 1;
     }
  
     file.contents = file.contents.split(',').pop(); // removed this when sent contents as blob
  
     fileBuffer = new Buffer(file.contents, "base64");
  
     fs.writeFileSync(filePath, fileBuffer);
  }
  </code></pre>
  
  <p>What am i missing? How can i write blob contents on file so that it can properly be saved as webm file?</p>