FriendsOfFlarum / upload

The file upload extension with insane intelligence for your Flarum forum.
https://discuss.flarum.org/d/4154
MIT License
175 stars 94 forks source link

Check MIME type & file size before upload #353

Open tipa opened 8 months ago

tipa commented 8 months ago

Feature Request

In my forum, I only want to allow image uploads (which are uploaded using the imgur adapter), so that no uploads are stored on my servers

image

At the moment, when the user uploads a file (either using drag & drop or copy-paste or manually using the file-picker), the file is uploaded first, and then it is checked if it exceeds the maximum file size or is of a MIME type that isn't supported

Is your feature request related to a problem? Please describe.

The reason I am submitting this feature request is that files of (failed and potentially very large) uploads are still stored in the /storage/tmp folder and fill up space on my webserver, which is what I want to avoid (that is the reason I am only allowing image files through the imgur adapter and don't want to store any uploads on my server)

Describe the solution you'd like

The plugin gathers as much information as it can as soon as possible to decide if an upload is possible to would error out anyways. For example, I would assume that when a file is selected with the file-picker, the file size could be queried before the upload process starts. Perhaps the MIME type can be determined based on the file extension. If that is not possible, maybe an additional option for admins to blacklist/whitelist file extensions would help