title: node/express download base64 image
body: <p>I am trying to download base64 data using node-express.As a result,image is not correctly,only show a black line!Actual, i just want to download a qr-code!!!</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>router.get('/download-qrcode', function (req, res, next) {
    var buf = req.query.image;
    buf = buf.split(',');
    buf = new Buffer(buf[1], 'base64');
    res.setHeader('Content-Type', 'image/png');
    res.setHeader('Content-Length', buf.length);
    res.setHeader("Content-Disposition", "attachment; filename=qrcode.png");
    res.end(buf, 'binary');
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>req.query.image value like 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA.....'</p>
  
  <p>Please advise ...Thanks for everyone..</p>