We have a scenario where we are using the Upload component and need to enforce a total upload size across all files selected for upload (e.g. 25 MB total).
Other than the necessary server-side checks for this, it is very beneficial for users to be informed of this on the front-end, so they do not get surprised by error messages after they try uploading.
There are a few ways that this could be achieved.
1) (Preferred) Add an option to the upload component for the total file size in bytes allowed (default is null/undefined). Show an error/message in the component if this is exceeded. Benefits of this approach:
2) Implement the requested feature to allows us to keep cancelled files in the queue (Ticket #1720671). If this is implemented, then we can check the overall files being uploaded at upload time and cancel the event + display an error manually. Benefits:
Drawbacks:
3) Add the ability to enable/disable the upload button directly in the component. Just setting the "disabled" status to true for the Upload doesn't work as it disables everything and makes it impossible for the user to removing the offending file(s). We can listen to select/remove/clear events, check the overall files being uploaded, display errors and then enable/disable the upload button. Quite a few drawbacks:
At the moment in our environment, we have to do a version of option 3) with workarounds to enable/disable the upload button as there isn't a method to do so directly.