Hey , we are trying to use the form to upload both images and videos
We added validators but they fail to prevent uploading mp4 (test).
const maxSize = (maxSizeInBytes) => (fileInfo) => {
if (fileInfo.size && fileInfo.size > maxSizeInBytes) {
throw new Error('size');
}
};
const allowedMimeTypes = (types) => (fileInfo) => {
if (fileInfo.mimeType && !types.includes(fileInfo.mimeType)) {
throw new Error('mimeType');
}
};
<Widget
tabs="file"
clearable={true}
crop="480x480"
inputAcceptTypes="image/*,video/mp4"
validators={[ maxSize(150 * 1024 * 1024), allowedMimeTypes(['image/jpeg', 'image/png', 'image/gif'])]}
onFileSelect={(file) => {
if (!file) {
formik.setFieldValue('imgUrl', '');
return;
}
if ('done' in file) {
file.done((fileInfo: { cdnUrl: any }) => {
formik.setFieldValue('imgUrl', fileInfo.cdnUrl);
});
}
}}
publicKey="23t65307c6fda2db4aae" // not actual key here
/>
"@uploadcare/nextjs-loader": "^1.0.0",
"@uploadcare/react-widget": "^2.3.0",
"@uploadcare/upload-client": "^6.4.1",
what is the best way to check these details before uploading to server ?