Skip to content
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

Hi....is there any way to send custom query values for the resumable POST request #7

Open
pconesa opened this issue Feb 18, 2016 · 0 comments

Comments

@pconesa
Copy link

pconesa commented Feb 18, 2016

I need to send in the POST (chunks) request 2 parameters.

If I initialize DjangoResumable like this:

document.addEventListener("DOMContentLoaded", function () {
   "use strict";
   var dj;
   if (new Resumable().support) {

      var resumableOptions =  {
         query: {
            'p': 'betagal1'
         }
      };

      var djangoResummableOpts = {
         resumableOptions: resumableOptions
      }

      dj = new DjangoResumable(djangoResummableOpts);
   }
});

the resumableOptions are overwritten during the initResumable:

opts = {
   target: el.getAttribute(this.options.urlAttribute),
      query: {
         'csrfmiddlewaretoken': this.csrfToken
      }
   };

opts = this.extend(this.options.resumableOptions, opts);

In the extend method, the whole query method (my customized options) are replaced by the 'default' ones ( the one with the 'csrfmiddlewaretoken')

Something that will fix it will be to recursively call extend if an object is found: and present in target:

            // Customize extend function to avoid query params to be overwritten
                DjangoResumable.prototype.extend = function (target, source) {
                    "use strict";
                    var property;
                    for (property in source) {
                        if (source.hasOwnProperty(property)) {
                            if (target[property] !== undefined && typeof source[property] === 'object') {
                                target[property] = this.extend(target[property], source[property]);
                            } else {
                                target[property] = source[property];
                            }

                        }
                    }
                    return target;
                };
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