LPology / Simple-Ajax-Uploader

Javascript file upload plugin with progress bar support. Works in all major browsers, including IE7+, Chrome, Firefox, Safari, and Opera. No dependencies - use it with or without jQuery.
995 stars 268 forks source link

customHeaders are encoded #93

Closed JohnMcAvinue closed 9 years ago

JohnMcAvinue commented 9 years ago

I'm using Bearer authentication and need to pass an authorisation token in the header in the format "Bearer AuthTokenValue".

I'm setting the customHeaders like this:

customHeaders: { "Authorization": "Bearer " + self.Parent().accessToken() },

This results in the following being sent:

Bearer%205MZVwIi9E3-J

It should be:

Bearer 5MZVwIi9E3-J

Is there a way to prevent this encoding from happening?

Thanks

madand commented 9 years ago

Hi @JohnMcAvinue , while maintainer not merged my pull request, you can download SimpleAjaxUploader.js from my fork:

var uploader = new ss.SimpleUpload({
      button: 'upload-btn',
      url: '/PathTo/UploadHandler',
      name: 'uploadfile',
      // add the following new option:
      encodeCustomHeaders: false
});

Please note, that only the main not-minified file (SimpleAjaxUploader.js) is patched, while SimpleAjaxUploader.min.js - is not!

JohnMcAvinue commented 9 years ago

Thanks very much. I ended up removing the encoding myself but it's obviously better to have it based on a setting. I appreciate you sharing it, thanks!