From 145c0834bb9ead7c5c5dc26b0662a9bb8ff72853 Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Thu, 20 Apr 2023 15:21:50 +0100 Subject: [PATCH] Fix for #10358 - making sure that client-side we don't check the content type for CSV, check if it might be JSON, if not assume we can try it as a CSV - this is a fix for an issue which occurs on Windows, in Firefox. (#10359) --- .../backend/TableNavigator/utils.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/builder/src/components/backend/TableNavigator/utils.js b/packages/builder/src/components/backend/TableNavigator/utils.js index 658f037912..b7e46042be 100644 --- a/packages/builder/src/components/backend/TableNavigator/utils.js +++ b/packages/builder/src/components/backend/TableNavigator/utils.js @@ -42,16 +42,7 @@ export const parseFile = e => { reader.addEventListener("load", function (e) { const fileData = e.target.result - - if (file.type === "text/csv") { - API.csvToJson(fileData) - .then(rows => { - resolveRows(rows) - }) - .catch(() => { - reject("can't convert csv to json") - }) - } else if (file.type === "application/json") { + if (file.type?.includes("json")) { const parsedFileData = JSON.parse(fileData) if (Array.isArray(parsedFileData)) { @@ -62,7 +53,13 @@ export const parseFile = e => { reject("invalid json format") } } else { - reject("invalid file type") + API.csvToJson(fileData) + .then(rows => { + resolveRows(rows) + }) + .catch(() => { + reject("cannot parse csv") + }) } })