title: NodeJS write base64 image-file
body: <p>My NodeJS-Server receives a picture base64 encoded.</p>
  <pre><code>data:image/jpeg;base64,/9j/4QCcRXhpZgAASUkqAAgAAAA ... CiiigD//Z
  </code></pre>
  <p>The received data should be saved as jpg. Therefore I use a Buffer and the FileSystemWriter:</p>
  <pre><code>var imageBuffer = new Buffer(data, 'base64'); //console = &lt;Buffer 75 ab 5a 8a ...
  fs.writeFile(&quot;test.jpg&quot;, imageBuffer, function(err) { //... });
  </code></pre>
  <p>the fs.writeFile doesn't throw an error. A jpeg-file is saved, but I can't open it.
  Image-Viewer says:</p>
  <pre><code>File is damaged or too big.
  </code></pre>
  <p>The original file is 6kb large and the new file 7kb.</p>