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

An oversized file breaks successive files uploads if it is first photo processed for uploading (first dropped into the dropzone) #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pyhammond
Copy link

This fixes a bug where if the 1st file dropped into the dropzone was oversized (greater than the maxFilesize) then the successive photos would not properly process.

This was due to the "if" condition here returning "true" when it was the 1st file in the queue and the other files had not yet been "added" to the queue yet.

My fix waits for 1s now and re-checks to be sure the queue is still empty before emitting the "queuecomplete" event.

Behavior Description

If the first image dropped into the dropzone happens to be too large when compared against the maxFilesize setting, the rest of the files will not properly upload and will not fire a success event because the queuecomplete event gets called too early.

To Reproduce

To reproduce the behavior:

  1. Create event handlers for the success, error and queuecomplete events in your init function used by dropzone.js
  2. Set break points at the top of the the success and error event handler code from step 1
  3. Drop multiple files into the dropzone - make sure the oversized photo is the first one to process
  4. Notice that once the error callback is called once, the success callback never fires for the photos that were not oversized

This does not happen if the oversized photo is 2nd or later in the group of photos to process. It only happens if it is the 1st one to process.

…oversized (greater than the maxFilesize) then the successive photos would not properly process.

This was due to the "if" condition here returning "true" when it was the 1st file in the queue and the other files had not yet been "added" to the queue yet.
My fix waits for 1s now and re-checks to be sure the queue is still empty before emitting the "queuecomplete" event.
@pyhammond
Copy link
Author

Taken from an issue I posted at dropzone#2322

Nicolas asked me to create a pull request for my fix.

@NicolasCARPi
Copy link
Owner

Hello,

Thank you for submitting this pull request.

Unfortunately, I could not reproduce the issue. As you can see in this screenshot:
2025-01-09-231107_831x787_scrot

I upload a few too big files, and then there is a correct one. There is a queuecomplete event fired for each, which I do not understand why TBH. It should only fire once, right? (when uploading all files at once of course).

See the codepen (with current stable release):

https://codepen.io/Osef1212/pen/RNbQdgK

I suggest that you fork the codepen and provide code showing the issue at play, as I'm unable to for now :/

Cheers,
~Nico

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

Successfully merging this pull request may close these issues.

2 participants