title: Saving a base 64 string to a file via createWriteStream
body: <p>I have an image coming into my Node.js application via email (through cloud service provider Mandrill). The image comes in as a base64 encoded string, email.content in the example below. I'm currently writing the image to a buffer, and then a file like this:</p>
  
  <pre><code>//create buffer and write to file
  var dataBuffer = new Buffer(email.content, 'base64');                        
  var writeStream = fs.createWriteStream(tmpFileName);
  
  writeStream.once('open', function(fd) {
      console.log('Our steam is open, lets write to it');
      writeStream.write(dataBuffer);
      writeStream.end();
  }); //writeSteam.once('open')
  
  writeStream.on('close', function() {
      fileStats = fs.statSync(tmpFileName);
  </code></pre>
  
  <p>This works fine and is all well and good, but am I essentially doubling the memory requirements for this section of code, since I have my image in memory (as the original string), and then create a buffer of that same string before writing the file? I'm going to be dealing with a lot of inbound images so doubling my memory requirements is a concern.</p>
  
  <p>I tried several ways to write email.content directly to the stream, but it always produced an invalid file. I'm a rank amateur with modern coding, so you're welcome to tell me this concern is completely unfounded as long as you tell me why so some light will dawn on marble head.</p>
  
  <p>Thanks!</p>