title: How to convert a Buffer object to a file in Node.js?
body: <p>I'm developing a web application using (MySQL)EAN stack. I saved png/jpg/pdf as BLOB in MySQL. Now, I can retrieve them as Buffer objects in Node.js by using <a href="http://sequelize.readthedocs.org/en/latest/docs/associations/#one-to-one-associations" rel="nofollow">Sequelize.js</a>:</p>
  
  <pre><code>exports.loadUploadedFiles = function(req, res) {
      db.File.findAll().success(function(files) {
         //res.send(files[0].dataValues.data.toString('ascii')); // I have tried to convert a Buffer to ascii and sent it to Angular.js, however, I still don't know how to transform them to a file link.
         res.send(files); // How can I return the Buffer objects to Angular.js
      }).error(function(err) {
          console.log(err);
          res.sendStatus(500);
      });
  };
  </code></pre>
  
  <p>I have tried two approaches: </p>
  
  <ul>
  <li><p>Return the Buffer objects to Angular.js, then, find a way to generate downloadable links from them. </p></li>
  <li><p>Convert the Buffer objects to ascii by using bufferObject.toString('ascii'), then, find a way to transform these ascii to downloadable links</p></li>
  </ul>
  
  <p>I have been trying for a day and still can't figure it out in both approaches :( , any suggestion would be highly appreciated!</p>