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)
This commit is contained in:
parent
d21f8435d6
commit
145c0834bb
1 changed files with 8 additions and 11 deletions
|
@ -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")
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue