Skip to content

Commit 8bfe403

Browse files
authored
Merge pull request #1017 from nk-coding/bugfix/csv_import
fix csv upload: accept correct content type
2 parents f313021 + 531c264 commit 8bfe403

2 files changed

Lines changed: 3 additions & 8 deletions

File tree

client/src/components/UploadFileButton.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,14 @@ function UploadFileButton({
3939
async (file: File) => {
4040
setLoading(true);
4141

42-
if (!supportedFileTypes.includes(file.type)) {
43-
return;
44-
}
45-
4642
const content: string = await file.text();
4743
const cb = onFileSelect(content, file);
4844

4945
await Promise.resolve(cb);
5046

5147
setLoading(false);
5248
},
53-
[supportedFileTypes, onFileSelect]
49+
[onFileSelect]
5450
);
5551

5652
const handleFileUpload = useCallback(
@@ -77,7 +73,7 @@ function UploadFileButton({
7773
>
7874
<Box display='flex'>
7975
<input
80-
accept='.csv'
76+
accept={supportedFileTypes.join(',')}
8177
style={{ display: 'none' }}
8278
id='icon-button-file'
8379
type='file'

client/src/components/import-csv/components/ImportCSVFromFile.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Box, Grow, Typography } from '@material-ui/core';
22
import { FileCheckOutline as FileSelectedIcon } from 'mdi-material-ui';
3-
import React from 'react';
43
import OutlinedBox from '../../OutlinedBox';
54
import UploadFileButton from '../../UploadFileButton';
65

@@ -18,7 +17,7 @@ function ImportCSVFromFile({ fileInfo, onFileInfoChanged }: ImportCSVFromFilePro
1817
return (
1918
<>
2019
<UploadFileButton
21-
supportedFileTypes={['application/vnd.ms-excel']}
20+
supportedFileTypes={['text/csv']}
2221
onFileSelect={(content: string, file: File) =>
2322
onFileInfoChanged({ content, fileName: file.name })
2423
}

0 commit comments

Comments
 (0)