title: How to overwrite DropzoneJS's XHR for GridFS?
body: <p>I'm currently developping an image sharing plateform, using Meteor, CollectionFS and GridFS StorageAdapter.</p>
  
  <p>I'm also using the excellent package <a href="https://atmospherejs.com/dbarrett/dropzonejs" rel="nofollow noreferrer">dbarrett:dropzonejs</a>, but problem is its implementation for CollectionFS, especially regarding XHR and uploadprogress stuff.</p>
  
  <p>For now, i use <a href="https://stackoverflow.com/questions/31715544/dropzone-file-not-fully-processed-when-calling-processfilefile">this code</a>.</p>
  
  <p><strong>Problem</strong> : when uploading files, i noticed in console unwanted POST requests
  alongside PUT requests from CollectionFS.
  I narrowed them down to xhr.send() in dbarrett_dropzone.js file.
  In attempt to stop them, i tried in template.rendered > dropzone options :</p>
  
  <pre><code>init: function() {
      this.on("sending", function(file,xhr) {
          xhr.abort(); //file.xhr.abort() does not work either...
      });
  } // console shows "NS_ERROR_NOT_INITIALIZED"
  </code></pre>
  
  <p>or overwriting dropzone.accept :</p>
  
  <pre><code>},
  accept: function(file,done) {
      done("dummy message");
  },
  </code></pre>
  
  <p>but then it prevents Queue array to be populated, which is needed for CollectionFS inserts...</p>
  
  <p><strong>Question</strong>: i think needs to overwrite dropzone.uploadFiles(files) function, where all the xhr stuff is written,
  ... but all my attempts failed, can someone propose an implementation please ?</p>
  
  <p>Ideally, i'm thinking such implementation would be like this :</p>
  
  <pre><code>Template.albumContent.rendered = function() {
      var dz = new Dropzone("form#dzId", {
          url: "#",
          autoProcessQueue: false,
          addRemoveLinks: true,
          acceptedFiles: "image/*",
          init: function() {
              this.on("success", function(file) {
                  Meteor.setTimeout(function() {
                      dz.removeFile(file);
                  },3000)
              });
          },
          uploadFiles: function(files) {
              var dzgqf = dz.getQueuedFiles();
              if (dzgqf.length) {
                  dzgqf.forEach(function(file) {
                      var fsFile = new FS.File(file);
                      fsFile.owner = Meteor.userId();
                      Images.insert(fsFile, function(error, fileObj) {
                          if (error) throw new Meteor.Error("Error uploading this file : ", fsFile);
                          // how to pass properly fileObj.updateProgress() stuff to dz.uploadprogress event ???
                      });
                  });
              }
          }
      });
  }
  
  Template.albumContent.events({
      "click .js-upload-all-images": function(event, template) {
          event.preventDefault(); event.stopPropagation();
          var dz = Dropzone.getElement("#dzId").dropzone;
          console.log("Queued files : ", dz.getQueuedFiles());
          dz.processQueue();
       }
  });
  </code></pre>