Merge pull request #279 from bknd-io/fix/dropzone-improve-mime

fix: dropzone improve mime type validation
This commit is contained in:
dswbx
2025-10-24 15:11:19 +02:00
committed by GitHub
3 changed files with 78 additions and 4 deletions

View File

@@ -9,8 +9,8 @@ import {
useEffect,
useMemo,
useRef,
useState,
} from "react";
import { isFileAccepted } from "bknd/utils";
import { type FileWithPath, useDropzone } from "./use-dropzone";
import { checkMaxReached } from "./helper";
import { DropzoneInner } from "./DropzoneInner";
@@ -173,12 +173,14 @@ export function Dropzone({
return specs.every((spec) => {
if (spec.kind !== "file") {
console.log("not a file", spec.kind);
console.warn("file not accepted: not a file", spec.kind);
return false;
}
if (allowedMimeTypes && allowedMimeTypes.length > 0) {
console.log("not allowed mimetype", spec.type);
return allowedMimeTypes.includes(spec.type);
if (!isFileAccepted(i, allowedMimeTypes)) {
console.warn("file not accepted: not allowed mimetype", spec.type);
return false;
}
}
return true;
});