title: How to make the browser download .csv file from a node / express application
body: <p>In my node /express app I have the following server-side file download function:</p>
  
  <pre><code>app.get('/download_playcards_export', function(req, res){
  
              var file = fs.createReadStream('/Users/eugene/Documents/dev/node/DataManager/PlayCards.csv');
              var stat = fs.statSync('/Users/eugene/Documents/dev/node/DataManager/PlayCards.csv');
              res.setHeader('Content-Length', stat.size);
              res.setHeader('Content-Type', 'text/csv');
              res.setHeader('Content-Disposition', 'attachment; filename=PlayCards.csv');
              file.pipe(res);
          }
      );
  </code></pre>
  
  <p>I can see the contents of my .csv file on the browser console:</p>
  
  <pre><code>$scope.exportPlaycardsData = function(){
  
                          $http.get('/download_playcards_export').success(function(response) {
                              console.log('success downloading playcards export  ' + response);
                          });
              }
  </code></pre>
  
  <p>But I am unable to make the browser just DOWNLOAD this file.</p>
  
  <p>What can I do to fix this?</p>