I'm creating a Dropzone programmatically in my Meteor application and instead of posting Files to a url I'm storing them inside my MongoDB with CollectionFS / GridFS and call processFile(File) for each one by iterating over the getQueuedFiles array, like so:
dz.getQueuedFiles().forEach(function(element) {
Images.insert(element, function(err, fileObj){
if (err){
alert("Erreur!");
} else {
var imageId = fileObj._id;
arrayOfImageIds.push(imageId);
dz.processFile(element);
}
})
All goes well until the File sizes are bigger. Then, somehow the progress bar gets stuck halfway and the processFile is never finished (and the queue not emptied). Even when I just isolate the dz.processFile(element) and comment out the DB writing the file hangs in the client.
This is my Dropzone setup:
Template.logoUpload.onRendered(function (){
Dropzone.autoDiscover = false;
dz = new Dropzone("form#dropzone", {
dictDefaultMessage : "DROP YOUR LOGO HERE",
autoProcessQueue: false,
addRemoveLinks: true,
dictRemoveFile: "Delete",
maxFiles: 2,
maxFilesize: 5,
maxThumbnailFilesize: 5,
accept: function(file, done){
done();
},
init: function() {
this.on("addedfile", function(file) {
Session.set("files", this.files.length);
if (this.getAcceptedFiles().length > 1) {
alert("max 2 files allowed");
this.removeFile(file);
}
}),
this.on("removedfile", function(file) {
Session.set("files", this.files.length);
}),
this.on("queuecomplete", function(file, response){
console.log("SUCCESFULLY UPLOADED");
console.log(arrayOfImageIds);
Session.set("imageIds", arrayOfImageIds);
})
}
});
});
Anyone have an idea how to solve this?