Needs review
Project:
DropzoneJS
Version:
8.x-2.7
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Apr 2020 at 14:03 UTC
Updated:
10 Jun 2026 at 12:40 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
semiaddict commentedThe attached patch is my first take at supporting chunked uploads.
Note that one breaking change has been introduced:
The UploadHandlerInterface::getFilename no longer accepts a UploadedFile, but a string with the original filename.
Comment #3
semiaddict commentedComment #4
semiaddict commentedHere's a new patch that also adds chunking options to the entity browser widget.
Comment #5
steveoriolI have an error ta the end...

Comment #6
semiaddict commented@steveoriol, what version of the DropzoneJs library are you using?
Can you try with the latest version (5.7.0)?
I believe older versions had issues with chunked uploads. See https://gitlab.com/meno/dropzone/-/commit/f0c93d34fda2a6ed11f1d5b8fe7c64...
Comment #7
steveoriolYES ! ;-) ... It is working with v5.7.0
Thank you
But, the resulting file is always rename with ".txt" at the end.
Comment #8
semiaddict commentedSuper!
I'm attaching an updated patch to indicate the requirement of version 5.7.0+ for chunked uploads.
Comment #9
semiaddict commentedNew patch with fixed white space issues.
Comment #10
steveoriolHello semiaddict,
I still notice that an '.txt' extension is each time add to the file name.

Comment #11
semiaddict commented@steveoriol,
Does that also happen with chunking disabled ?
The ".txt" extension was already being added for security reasons by the module before I created the patch, but it should normally be removed once the uplaod is done.
I personally haven't experienced this issue, but I'm not using the eb_widget. Are you ?
Comment #12
steveoriolIf I uncheck "Enable chunking" in the "Widget Settings"(/admin/config/content/entity_browser/dropzone_test/widgets) the ".txt" extension is not added.
Comment #13
semiaddict commentedThe issue seems to happen when the ChunkedUploadHandler is used even if the file is not chunked due to small filesize.
I have fixed this issue in the attached patch as well as a library dependency issue.
Comment #14
semiaddict commentedComment #15
steveoriolOK semiaddict, It is working for me with patch #13, I tryed with small et big file chunked and the problem is gone ;-)
Thank you
Comment #16
semiaddict commentedSuper.
I'm putting status back to "Needs review" to notify maintainers that the patch is ready for review.
Comment #17
jungleThanks all for working on this. It's a great feature. I would commit it as soon as possible as a new co-maintainer. But would be great to have tests coverage if possible. I guess @semiaddict forgot to unassign, so unassigning. What if others want to pick this up.
Comment #18
semiaddict commentedComment #19
semiaddict commentedHere's an updated patch that applies on 8.x-2.3 and the latest dev.
I unfortunately do not have the time to add tests for the moment.
Comment #20
macdev_drupal commentedI've applied the Patch but I get an error with the php filesize limit. Do I have to raise the php limits? Thougt this patch would help to avoid raising the limits

Comment #21
semiaddict commented@macdev_drupal could you please provide more information such as:
Comment #22
macdev_drupal commentedError Message from Server:
Error Message from Drupal Log:
Pfad: /dropzonejs/upload?token=ptgfZzMr1dQ6JSB3-hX-m7WSgQ-OyxxbNwmOVswemE0. Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException: in Drupal\dropzonejs\Controller\UploadController->handleUploads() (Zeile 63 von /var/www/html/web/modules/contrib/dropzonejs/src/Controller/UploadController.php).post_max_size = 100MB
upload_max_filesize = 100MB
File Size is 251MB
Used the Media Bulk Upload Modul https://www.drupal.org/project/media_bulk_upload
Filesize Limit is set to 2000MB
My Intention would be not to raise the PHP limits but let People Upload large files via chunks.
Comment #23
semiaddict commented@macdev_drupal,
The media_bulk_upload uses a dropzonejs form element directly.
So its code would need to be changed to allow setting chunking options on the form element. But this will most likely not happen before this issue is closed and the patch merged with the dropzonejs module.
What you could do in the meantime is implement a hook_form_alter in one of your custom module to add the chunking options to the media_bulk_upload form.
This would look something like this:
Don't forget to change 'mycustommodule' with your module's name!
I haven't tested this, but I believe it should work as long as the patch in this issue is applied.
If it doesn't, please create a separate "Support request" issue, as this is not exactly the right place for it.
Comment #24
lussolucaI'm trying the patch in #19 and it works, but I've to comment out (or manually set to a big number) the line
'maxFilesize' => $max_size,in DropzoneJs::preRenderDropzoneJs, otherwise I got aFile is too bigerror.I'm missing something?
Comment #25
semiaddict commentedHello lussoluca,
This is unrelated to the patch.
The limit is likely set by the file field settings.
Can you double check you settings or try to trace the source of the $max_size variable ?
Comment #26
lussolucaYes you're right,
I wasn't set the max upload size for the field because I thought that it cannot be bigger than the PHP's max upload size, but it could be.
Sorry for the noise and thanks for the patch
Comment #27
spadxiii commentedDid a quick re-roll on latest dev
Comment #28
spadxiii commentedDid another quick re-roll on latest dev - and uploaded the wrong file :( retry in next comment
Comment #29
spadxiii commentedReroll, attempt 2
Comment #30
spadxiii commentedThe third time is the charm! :crossed_fingers:
Comment #31
dishabhadra commentedI applied the #30 patch in my application of Drupal 9, patch got applied successfully but it's not working.
After enabling the chunks upload, the file is getting uploaded in chunks but when we click on select entities getting the error.
I debugged the issue and my findings are:
Comment #32
dishabhadra commentedComment #33
dishabhadra commentedTo solve #31 error related to the filename, I added some changes in the js file and updated the patch.
Please review.
Comment #34
dishabhadra commentedComment #35
stefan.korn@dishabhadra: Not sure why you had these issues.
Code you added at:
does never get called if you use chunked upload imho (see comment 'Chunked uploads get an empty response').
Which version of dropzone JS are you using?
Comment #36
abautu commentedI have prepared and tested a smaller patch. It doesn't offer all the features from the previous patches, but I'm adding it here in case it helps anyone.
It does only these things:
- enables chunking on all dropzone elements (using default chunk size of 2M from DropzoneJS)
- fixes missing response in the succes callback (in 5.7, the response parameter of success callback is an empty string for chunked uploads; this has been changed in 5.9 to be consistent between chuncked and regular uploads)
- fixes the upload callback to correctly write/append each chunk.
I tested it by uploading files from 5 to 200MB on a PHP server with 20MB upload limit.
Comment #37
abautu commentedPatch from #36 failed to apply to dev. I updated it here.
Comment #38
nicasso commentedI made some additional changes to patch #33, that @dishabhadra provided:
- I force the usage of chunking.
- I added a new settings value (max_filesize_default) to be able to set a new maximum file size, thus not depening on the PHP upload_max_filesize value
- Changed the getting of CSRF tokens, to make chunking work for the Media library widget
With these changes chunking now works for me in the following 2 places:
- Bulk upload (admin/content/media/bulk-upload)
- Media library widget
Patch applies on Dropzonejs version 2.8.0 and I used it with in combination with the Dropzone library version 5.9.3.
Complete patch + interdiff with #33 provided.
Comment #39
nicasso commentedPatch file in #38 contained a mistake with info.yml files.
Correct it here in this patch.
Comment #40
nicasso commentedWhen using lightning media, you might also want to include this patch in combination with the path from #39.
Comment #41
vincent signoret commentedI applied patch #39 with
I had a media 'document' containing a field of type File. This field has a maximum file size of 1000 MB. I added a widget to the display form of this field of type Entity Browser. This widget has the following configuration settings:
When I tried to upload a file (900MB) I always have the error "File is too big (XXXMiB). Max filesize: XXXMiB."
With some debuging in DropzoneJsEbWidget.php line 165 the
$config = $this->getConfiguration();returned the configuration I had set in the entity browser widget, except for the max_file_size. The max_file_size alwayss returned the value of my upload_max_filesize in my php.iniI have tried previous patches and different versions of enyo/dropzone, but I always face the same issue.
Comment #42
uberengineer commentedPatch #39 does not apply to dropzonejs 2.10.0
Comment #44
semiaddict commentedJust created a fork and a merge request on the latest version: https://git.drupalcode.org/project/dropzonejs/-/merge_requests/14
Comment #45
nicasso commented@uberengineer, hereby an updated patch for 2.10.0
Comment #46
boazpoolman commentedRerolled the lightning_media patch for version 5.0.0.
Comment #47
glynster commentedWhat’s the holdup on merging the PR? We use this in production across multiple websites. What can we do to get this moved into a new release?
Comment #48
semiaddict commented@glynster, I believe tests are still missing.
Comment #49
glynster commentedAh ha good to know semiaddict. As you are the creator of this wonderful gem will you be adding the testing or waiting on the maintainers?
Comment #50
nojj commentedI tested MR14 but have the same issue as #41
if php upload_max_filesize is smaller the file size I am trying to upload, the error that file is too big referring at the limit of the PHP Limit.
Comment #51
berdirTesting this as we finally have a use case for this.
The chunked upload itself seems to work fine, however, then nothing happens.
Debugging a bit, I can see that despite the comment saying otherwise,
dropzoneInstance.on('success'is in fact called with a response, on the last part, *after* Drupal.dropzonejs.chunksUploaded, and it has result filename with the last part. This overrides file.processedName, this is then submitted and obviously the server then doesn't find that anymore.This is with dropzone 6.x beta2 so there might have been a change with that.
Commenting out that line as a quickfix solves that and the media can then be edited. But it needs a better check, maybe by checking if file.processedName is already set and then assuming that it was set by the chunk response so that it's compatible with different versions?
Also, if you have problems with max file size, then you might be on an old core version, #2867336: File size validator should only respect the explicitly configured maximum file size should have resolved that.
Comment #52
jackfoust commented@bedir you're seeing a 500 error on finalize with MR14? If so, what line did you end up commenting out?
Comment #53
interx commentedI can confirm the comment #51 with MR14 and dropzone 6.0.0-beta.2. The success event does have a respone for the last uploaded chunk (eg. myfile.mp4.txt.part9). This overwrites the uploadedFilesElement value. So the comment " Chunked uploads get an empty response." is not entirely correct. I am unsure if this is only in 6.0.0-beta.2.
I fixed it by checking if the instance uses chunking:
Ir works fine after this small change.
Comment #54
loze commentedTried testing the MR. it applied, but I was unable to get it to work.
The images appear to upload in dropzone. but when I click the submit button I get an error message "At least one valid file should be uploaded."
and in the js console i have
Both the EB Media Dropzone widget, and the EB Media Dropzone widget with edit widet.
Comment #55
interx commentedI tried to reproduce the error, but it seems to work normally for me (inside EB or Webform element).
From the error it looks like the instance inst registered in drupalSettings.dropzonejs.instances. Dit you configur ethe EB widget as Dropzone plugin?
Comment #56
arno_vghI can confirm comment #54. Uploading file(s) with the EB widget plugins '
dropzonejs_media_entity_inline_entity_form' and 'dropzonejs_media_entity' does not work correctly with chunked uploads.The current logic determines whether an upload is chunked by inferring it indirectly from totalChunkCount while Dropzone already exposes the correct per-file flag on the client side: file.upload.chunked. This is also important for the filename handling.
Comment #57
arno_vgh