t3dotgg / quickpic

Turn SVGs into high resolution PNGs in 2 clicks. Built because Theo was mad.
https://quickpic.t3.gg
MIT License
892 stars 177 forks source link

feat: Add file validation for specific file extensions, mimes or both. #65

Open AbrahamX3 opened 1 week ago

AbrahamX3 commented 1 week ago

Description

This PR adds file type validation using sonner toast errors and fixes https://github.com/t3dotgg/quickpic/pull/36#issuecomment-2467326103

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 inside acceptedFileTypes), 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

https://github.com/user-attachments/assets/f672a8df-6a98-4aef-a1e1-ede5fb8885da

vercel[bot] commented 1 week ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
quickpic ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 13, 2024 3:03am