Skip to content

Commit

Permalink
fix(ui): fix CoreDataFrame download for big file. WF-39
Browse files Browse the repository at this point in the history
The issue was too many parameters was given to `String.fromCharCode()` and make and error like "Maximum call stack size exceeded".

In fact, there is no need to try to convert the CSV to base64. So I simply used `Blob` and then `URL.createObjectURL` instead which should be more efficient.
  • Loading branch information
madeindjs committed Jul 25, 2024
1 parent 0aef7a2 commit 84321c1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/ui/src/core_components/content/CoreDataframe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,13 @@ function download() {
const csv = table.value.toCSV();
const el = document.createElement("a");
// btoa only supports ASCII
const blob = new Blob([csv], { type: "text/csv" });
const url = URL.createObjectURL(blob);
const s = String.fromCharCode(...new TextEncoder().encode(csv));
el.href = "data:text/plain;base64," + window.btoa(s);
el.href = url;
el.download = "data.csv";
el.click();
URL.revokeObjectURL(url);
}
async function applyOrder() {
Expand Down

0 comments on commit 84321c1

Please sign in to comment.