1

In my server side i'm generating csv file with some data.when user click on download button i want to send this csv and download it on user's browser.

server script Node.js

 exports.downCsv = (req, res) => {

            var file =req.query.csvUrl;
            res.sendFile(path.resolve(__dirname +'/../../'+config.tempCsvDir+'/'+file));

    };

Client side AngularJS

 var downCSV=function(url){

    Common.get('api/reports/downCsv?csvUrl='+url+'',
    {},function (get_data){

      if(get_data){

          console.log("",get_data);
      }else{
          console.log("error",get_data.message);
      }
    });

  };

when i click download button,console.log showing data inside of csv file.but i want user to download it.

Tje123
  • 729
  • 17
  • 44
  • but i want to send my csv file from server side to client. when i use ` – Tje123 Jul 28 '17 at 07:27
  • You can simply add the file under static folder of your node app (Similar to js and css file, some other file say media/assets). and that link will download the file for sure. I had similar requirement few days ago and I have done that and it had worked fine for me. – undefined Jul 28 '17 at 08:36

0 Answers0