Skip to content

uploadMaxChunkSize not fully respected; chunking defaults to ~2MB due to internal uplMaxSize behavior, and uploadMaxChunkSize: 0 hangs browser #3717

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

Open
bahrikutlu opened this issue May 23, 2025 · 0 comments

Comments

@bahrikutlu
Copy link

Describe the bug
When attempting to configure file uploads, uploadMaxChunkSize does not behave as expected:

  1. Setting uploadMaxChunkSize to a large value (e.g., 1GB) still results in files being chunked at approximately 2MB.
  2. Setting uploadMaxChunkSize: 0 (intending to disable chunking) causes the browser to hang, even for very small files (e.g., 2KB).

Investigation into the elFinder source code (specifically the upload handling function, around line where effective chunk size Y is calculated) reveals a line similar to:
Y = Math.min((this.uplMaxSize ? this.uplMaxSize : 2097152) - buffer, this.options.uploadMaxChunkSize)

It appears this.uplMaxSize defaults to NaN or is not properly initialized from options, causing the 2097152 (2MB) default to always take precedence in the Math.min calculation if this.uplMaxSize is falsy (like NaN).

Furthermore, when this.options.uploadMaxChunkSize is 0, the calculated effective chunk size Y becomes 0. The subsequent file slicing logic file.slice(start, start + Y) then attempts to create 0-byte slices, likely leading to an infinite loop or browser hang.

To Reproduce

  1. Initialize elFinder with a backend connector.
  2. Set elFinder client option uploadMaxChunkSize: 1000 * 1024 * 1024 (1GB).
  3. Attempt to upload a file larger than 2MB (e.g., 5MB).
    o Expected behavior: File uploads in one chunk (or chunks respecting the 1GB limit).
    o Actual behavior: File is uploaded in ~2MB chunks. The filename for these chunks may appear as "blob" and Content-Type as application/octet-stream at the backend if the backend isn't equipped for chunking.
  4. Change elFinder client option uploadMaxChunkSize: 0.
  5. Attempt to upload any file (e.g., 2KB).
    o Expected behavior: File uploads as a single, non-chunked request.
    o Actual behavior: The browser UI hangs indefinitely.
    Workaround Found:
    Manually setting the internal property after initialization seems to allow uploadMaxChunkSize to be respected for larger chunk sizes:
    $('#elfinder').elfinder('instance').uplMaxSize = 50 * 1024 * 1024;
    This suggests uplMaxSize is not being correctly initialized or made configurable through standard options.
    Expected behavior
  6. uploadMaxChunkSize should correctly define the chunk size, or disable chunking if set to 0, without being overridden by a fixed ~2MB internal limit unless uploadMaxChunkSize is larger than that internal limit (if such a limit is intended by design and configurable).
  7. uploadMaxChunkSize: 0 should reliably disable chunking and not cause the browser to hang.
  8. The internal uplMaxSize property should either be configurable via options or initialized to a value that doesn't improperly restrict uploadMaxChunkSize.
    Environment
    • elFinder version: [Your elFinder Version, e.g., 2.1.65]
    • Browser name and version: [e.g., Chrome 136.0.7103.114]
    • jQuery version: [Your jQuery Version, e.g., 3.6.0]
    • Custom python connector for select commands needed. Upload handling is not setup for chunking which made this bug apparent.
    Additional context
    The primary issue seems to be the handling of the internal uplMaxSize variable and the logic for when uploadMaxChunkSize is set to 0. The workaround of manually setting instance.uplMaxSize indicates that if this internal variable had a proper large value, uploadMaxChunkSize would likely function more as expected for values greater than 2MB. The hang with 0 points to a flaw in the "disable chunking" path.
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

No branches or pull requests

1 participant