2

So , I have some thing like this in the back end. response.setContentType("text/csv; name=" + fileName); response.addHeader("content-disposition", "attachment; filename=\"" + fileName + "\"");

    try {
        final String csvBuilder = this.reportService.tripSummaryCsvBuilder(trips);
        response.getOutputStream().write(csvBuilder.getBytes());
    } catch (Exception e) {
        logger.error("downloadTripSummary() - Unexpected exception: ", e);
        throw new ServerErrorException("download trip summary csv file failed");
    }

So, All the back end code works fine. But the only problem here is I need to send like an ArrayList of 1000 objects to server , based on each element inside the arraylist the csv is built on the server.

If its a normal Http Get , it will works fine . But in this case, i need to use POST because I cant send 1000 objects as part of url.

I am using angular js on UI side . Could some one please assist me on how to do this ?

I have tried to use $http.post call using an ajax service in agular js, but the service is not able to pop up the window to save the file once the response is received.

user3329002
  • 156
  • 2
  • 9

1 Answers1

0

http://plnkr.co/edit/N5bMq7dJ4YPJrppR1PPt

Check this plunker, with fileSaver u can save as fileName.

I found it here

Community
  • 1
  • 1
madhured
  • 443
  • 2
  • 8