-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No error message when trying to upload a file that exceeds a FileInput
's maxSize
attribute
#6441
Comments
After doing some digging, it seems that we can pass through I also don't think it gives us a reason for why the file was rejected. I'm happy to hear what you folks have to think |
Thanks for reporting |
To fix this, we'll have to first upgrade to the latest react-dropzone version as they added the reason why a file has been reject in v11. However, what you're suggesting is that we treat the maxSize option (and probably all the others that filter the file such as minSize or accept) as validators. I'm marking this as a feature request but we won't address it before v4. |
Workaround: const handleDropRejected = useCallback((fileRejections: FileRejection[]): void => {
const errorMessage = fileRejections.flatMap(fr => fr.errors).map(err => err.message).join('; ');
notify(`Invalid file(s): ${errorMessage}`, { type: 'error' });
}, [notify]); <ImageInput options={{ onDropRejected: handleDropRejected }}>
<ImageField />
</ImageInput> |
@magicxor Thanks! Works like a charm. |
There was not enough traction from the community to justify that the core team works on this feature request. So I'll close this issue, but feel free to open a PR (agains react-admin v4) that implements it. |
What you were expecting:
If I try to upload a file via RA's
FileInput
and the file size exceeds the limit specified on themaxSize
property. I expect the FileInput to not add the file to the list of files to be uploaded, and to display an appropriate error message.What happened instead:
FileInput didn't add the file to the list of files to be uploaded (good)
FileInput didn't display any sort of error/validation message (bad)
I'm also not getting any helpful data via the
useField
'smeta
property.Steps to reproduce:
Add this code to your Create/Edit page
Then try to upload any file.
I have a repro case here
Here's a video of the problem in action:
maxFile.mov
The first file I chose was under 5mb, the second was over 5mb.
Environment
The text was updated successfully, but these errors were encountered: