uppy icon indicating copy to clipboard operation
uppy copied to clipboard

have maxFileSize check the file after compression/resizing via Compressor plugin

Open urkle opened this issue 2 years ago • 2 comments

Initial checklist

  • [X] I understand this is a feature request and questions should be posted in the Community Forum
  • [X] I searched issues and couldn’t find anything (or linked relevant results below)

Problem

When using maxFileSize restriction and the compressor plugin the file size check is applied to the original file size not the compressed and resized file.

for example I have users who want to upload ridiculously huge images from their phone (sometimes > 15MB). but I only want a much smaller image accepted, so I have Compressor configured to resize to a max 1024 width and 60% quality. thus I get a 100-200KB image, which is well below the server-accepted max of 3MB.

However, in order to accomplish that I have to set uppy's max size to a VERY large number, and lose the ability to show warnings about the 3MB actual limit post compression.

Solution

Have the ability to postpone the maxFileSize until later in the process.

Alternatives

?

urkle avatar Apr 19 '24 15:04 urkle

Hi, I understand this doesn't make sense but currently it's hard to change. Restrictions live inside @uppy/core and are called immediately when files are added. @uppy/compressor is a pre-processor called right before uploading.

It's probably best to disable restrictions in your case and create your own pre-processor, which you .use() after @uppy/compressor, and validate there.

Murderlon avatar Apr 22 '24 08:04 Murderlon

@Murderlon thanks. I ended up essentially doing that. Would be nice if there was some built-in way to do this.

urkle avatar Apr 28 '24 19:04 urkle