fix: added check to upload .md files correctly (#8017)
Added check to upload file type if file.type does not exist
This commit is contained in:
parent
d2919f228d
commit
0e6fc94dad
1 changed files with 3 additions and 5 deletions
|
|
@ -38,12 +38,10 @@ const useUploadFile = ({
|
||||||
for (const file of filesToUpload) {
|
for (const file of filesToUpload) {
|
||||||
validateFileSize(file);
|
validateFileSize(file);
|
||||||
// Check if file extension is allowed
|
// Check if file extension is allowed
|
||||||
const fileExtension = file.type
|
const fileExtension = file.name.split(".").pop()?.toLowerCase();
|
||||||
? file.name.split(".").pop()?.toLowerCase()
|
if (!fileExtension || (types && !types.includes(fileExtension))) {
|
||||||
: null;
|
|
||||||
if (types && (!fileExtension || !types.includes(fileExtension))) {
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`File type not allowed. Allowed types: ${types.join(", ")}`,
|
`File type ${fileExtension} not allowed. Allowed types: ${types?.join(", ")}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!fileExtension) {
|
if (!fileExtension) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue