I think that having a constraint on the max total file size of the uploads would be really handy.
My use case is that I use Uppy in a form that generates an email with Uppy uploads as attachments.
My email provider limits the total file size of attachments to 10M.
Setting max file size to 10M and number of uploads to 1 is a possible workaround for the moment but I would love to be able to handle multiple uploads.
Adding a max total file size in Uppy would mean I dont have to specify the number of files yet make sure the total file size of all uploads does not exceed 10M
Hi! I think this is a good idea, will add to todo, PRs welcome too! 馃憤
Here is my current workaround, sorry for my horrible JS (I am a backend Guy) 馃槃
```` javascript
var uppy = Uppy.Core({
id: "my-id",
autoProceed: false,
onBeforeFileAdded: (currentFile, files) => checkUpload(currentFile, files)
})
function checkUpload(currentFile, files) {
// 10MB
var maxTotalFileSize = 10485760;
var TotalFileSize = 0;
for (var key in files) {
TotalFileSize = TotalFileSize + files[key].size;
}
var grandTotalFileSize = currentFile.data.size + TotalFileSize;
if (grandTotalFileSize >= maxTotalFileSize) {
return Promise.reject('Max filesize exceded');
}
return Promise.resolve();
}
````
I did something similar with onBeforeFileAdded, but ran into an issue when selection multiple files are once. While it runs though onBeforeFileAdded for each of the select files, the second argument, files, is not updated between each execution. This means I don't have access to the rest of the files in order to get the total size of the previously selected files.
Added to backlog in changelog.md, closing for now, thanks for the suggestion!
I wonder is it possible to set maximum file size larger than 10 Mb? I am trying to use uppy to upload multiple photos, it would be nice if we can set maximum size larger, like 50 MB or other value. Thank you very much?
@sssomnus by default you can upload files of any size with Uppy. As for limits, if you set maxFileSize: 50 * 1024 * 1024 the file limit should be 50mb, does this work for you?
@purplefish32 The docs mention that onBeforeFileAdded() should be synchronous. Removing the Promise made your solution work for me.
Most helpful comment
Added to backlog in changelog.md, closing for now, thanks for the suggestion!