Dropzone uploads only 100 files of a folder which has >100 files #599

Open
anvarik opened this Issue May 26, 2014 · 4 comments

Projects

None yet

4 participants

@anvarik
anvarik commented May 26, 2014

Hi all,

Dragging and dropping files manually is being affected by the maxFiles; however dragging and dropping of a folder is always being ignored.

Scenario:
maxFiles is set to 300
Drag and drop 400 files => 300 uploaded which is correct
Drag and drop a folder with 400 files => 100 uploaded ?????

Whatever I do, only 100 of the files are being uploaded...

@anvarik anvarik changed the title from Dropzone does not upload a folder with more than 100 files to Dropzone does upload only 100 files of a folder which has >100 files May 26, 2014
@anvarik anvarik changed the title from Dropzone does upload only 100 files of a folder which has >100 files to Dropzone uploads only 100 files of a folder which has >100 files May 26, 2014
@anvarik
anvarik commented May 27, 2014

Ok I found the bug. dirReader.readEntries() does not read the whole folder. Here is what MDN says about DirectoryReader:

1.Call direcoryEntry.createReader() to create a new DirectoryReader.
2.Call readEntries().
3.Continue calling readEntries() until an empty array is returned. You have to do this because the API might not return all entries in a single call.

But in line 1092 of dropzone.js, in function Dropzone.prototype._addFilesFromDirectory; dirReader.readEntries() is called only once, instead of being called recursively, which takes 100 files and then does not continue.

I solved the issue on my local by rewriting Dropzone.prototype._addFilesFromDirectory, and if you want @enyo , I can make a pull request.

@brspurri
brspurri commented Jun 6, 2014

+1 for a pull request. I could use this feature as well.

@FalkoOXC

i changed one function a bit so folder with >100 works now Dropzone.prototype._addFilesFromDirectory = function(directory, path) {
var dirReader, entriesReader;
dirReader = directory.createReader();
entriesReader = (function(_this) {
return function(entries) {
var entry, _i, _len;
for (_i = 0, _len = entries.length; _i < _len; _i++) {
entry = entries[_i];
if (entry.isFile) {
entry.file(function(file) {
if (_this.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') {
return;
}
file.fullPath = "" + path + "/" + file.name;
return _this.addFile(file);
});
} else if (entry.isDirectory) {
_this._addFilesFromDirectory(entry, "" + path + "/" + entry.name);
}
}
/NEEEWWWWWW START/
if (entries.length>0){
dirReader.readEntries(entriesReader, function(error) {
return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(error) : void 0 : void 0;
});
}
/NEEEWWWWWW END/
};
})(this);
return dirReader.readEntries(entriesReader, function(error) {
return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(error) : void 0 : void 0;
});
};

@generalChaos

Looks like this bug is still prevalent in version 4.0. @enyo could you please include this fix for the next release?

@kevinkrouse kevinkrouse added a commit to kevinkrouse/dropzone that referenced this issue May 29, 2015
@kevinkrouse kevinkrouse Fixes enyo/dropzone#599
Recusively call dirReader.readEntries to upload > 100 files.
3d21009
@kevinkrouse kevinkrouse added a commit to kevinkrouse/dropzone that referenced this issue May 29, 2015
@kevinkrouse kevinkrouse Fixes enyo/dropzone#599
Recursively call .readEntries to upload > 100 files in a folder.
0617d18
@antpaw antpaw added a commit to antpaw/dropzone that referenced this issue Oct 18, 2015
@enyo @antpaw + antpaw Fix problem with more files than 100 in a directory a57046a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment