feat: Add file validation for specific file extensions, mimes or both. #65
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds file type validation using sonner toast errors and fixes #36 (comment)
Going through several refactors, I found in my opinion the best way to keep many things as unchanged as possible since from the looks of it, when uploading a file, it is handled in two instances, when dragging a file and when directly using the upload input.
This PR verifies if the file type is valid depending on what's given in
acceptedFileTypes
, it displays a custom message in case a tool supports only SVG's, any Images (if "image/*" wildcard is passed insideacceptedFileTypes
), specific extensions or even if in the future a tool need's a specific format such as a transparent image (a .png for example), this PR makes it easy to verify a specific file mime, extension, or both.Preview
chrome_63pZR7XbtY.mp4