From 62d7d8e317997f6355384ff4f75a98460bae481f Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 1 Sep 2022 12:43:21 +0800 Subject: [PATCH] fix(gui-v2): use mime types --- .../[projectId]/index/index/index.vue | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/index.vue b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/index.vue index f84902cfbe..c28edbe275 100644 --- a/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/index.vue +++ b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/index.vue @@ -20,13 +20,18 @@ type QuickImportTypes = 'excel' | 'json' | 'csv' const allowedQuickImportTypes = [ // Excel - '.xls, .xlsx, .xlsm, .ods, .ots', + 'application/vnd.ms-excel', // .xls + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', // .xlsx + 'application/vnd.ms-excel.sheet.macroenabled.12', // .xlsm + 'application/vnd.oasis.opendocument.spreadsheet', // .ods + 'application/vnd.oasis.opendocument.spreadsheet-template', // .ots // CSV - '.csv', + 'text/csv', // JSON - '.json', + 'application/json', + 'text/json', ] watch(files, (nextFiles) => nextFiles && onFileSelect(nextFiles), { flush: 'post' }) @@ -52,10 +57,11 @@ function onDrop(droppedFiles: File[] | null) { let fileType: QuickImportTypes | null = null const isValid = allowedQuickImportTypes.some((type) => { - const isAllowed = droppedFiles[0].type.replace('/', '.').endsWith(type) + const isAllowed = droppedFiles[0].type === type if (isAllowed) { - fileType = type.replace('.', '') as QuickImportTypes + const ext = droppedFiles[0].name.split('.').pop() + fileType = (ext === 'csv' || ext === 'json') ? ext : 'excel' as QuickImportTypes } return isAllowed