Issue
I have a javascript file that requests for data from server.The data has to be displayed in CSV format. The data size can reach huge limits. The following is the code I am using in javascript to download the file.
var tmp = document.createElement('a');
var csvData = new Blob([dataString], { type: 'text/csv' });
var csvUrl = URL.createObjectURL(csvData);
tmp.href = csvUrl;
tmp.setAttribute('download', "abc.csv");
tmp.click();
The file size if it reaches 50MB crashes the chrome. The chrome gives "aw snap" error. But I should be able to download data more than 1GB. How to download such huge CSV file without crashing chrome browser.
Solution
The approach of converting data to string and triggering click event was totally wrong. What really is required is to stream the file. The below link explains how to stream a file from HttpServlet's response object.
Streaming large files in a java servlet
Answered By - Mumzee
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.