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
|
@ -42,16 +42,7 @@ export const parseFile = e => {
|
||||||
|
|
||||||
reader.addEventListener("load", function (e) {
|
reader.addEventListener("load", function (e) {
|
||||||
const fileData = e.target.result
|
const fileData = e.target.result
|
||||||
|
if (file.type?.includes("json")) {
|
||||||
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") {
|
|
||||||
const parsedFileData = JSON.parse(fileData)
|
const parsedFileData = JSON.parse(fileData)
|
||||||
|
|
||||||
if (Array.isArray(parsedFileData)) {
|
if (Array.isArray(parsedFileData)) {
|
||||||
|
@ -62,7 +53,13 @@ export const parseFile = e => {
|
||||||
reject("invalid json format")
|
reject("invalid json format")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reject("invalid file type")
|
API.csvToJson(fileData)
|
||||||
|
.then(rows => {
|
||||||
|
resolveRows(rows)
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
reject("cannot parse csv")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue