Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
urkle opened this issue Apr 19, 2024 · 2 comments
Open
2 tasks done
Labels

Comments

@urkle
Copy link

urkle commented Apr 19, 2024

Initial checklist

  • I understand this is a feature request and questions should be posted in the Community Forum
  • 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 urkle added the Feature label Apr 19, 2024
@Murderlon
Copy link
Member

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.

@urkle
Copy link
Author

urkle commented Apr 28, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants