2

I have a problem with the headers that I passed in the ng-file -upload getting overwritten.

Upload.http({
               url:URL
               headers:{'Content-Type': application/json},
               data: file
            }).progress(function(evt) {
                      file.progress = Math.min(100, parseInt(100.0 *
                                         evt.loaded / evt.total));

            }).success(function(response) {

            }).error(function(response) {

            }); 

What I actually want is to pass the content type as null or undefined. The problem is I have configured chrome modify header add on to add headers to all requests.

I only want the file upload request to be made with content type 'empty'. But when I am adding the header parameter it is getting overwritten by the add on. I am not able to remove the add on as it will effect my other requests.

Can anyone help?

iWillGetBetter
  • 780
  • 1
  • 15
  • 35
Vishnu
  • 21
  • 1
  • I'll assume you have `'application/json'` as a string, correct? I can't imagine it would run without errors otherwise... It also has a `// only for html5` comment for the headers-field in the documentation. You have checked your doctype, right? – ippi Oct 12 '16 at 14:33
  • I would also try setting `$locationProvider.html5Mode(true);` in your config if you haven't done that. ([for example like this](http://stackoverflow.com/a/13833371/1497533)). I used ng-file-upload some time back and recall some similar issue. I couldn't find it however and thus I'm just sending you random ideas. Sorry, good luck. – ippi Oct 12 '16 at 14:44
  • i have 'application /json ' as a string..but really i want to pass it as undefined.But in the modify header chrome add on i have content type defined to 'application/json' which is required for all other request.i want to overwrite that with what i am passing in the header parameter in ng-file-upload – Vishnu Oct 12 '16 at 14:49
  • Since it relies on $http, I would try configurating the defaults. Inject $httpProvider In angular.config, and try setting `$httpProvider.defaults.headers.post = undefined;` – ippi Oct 12 '16 at 14:58
  • What do you mean by `chrome add on`. Do you mean you have a chrome plugin that modifies the xhr request headers? – danial Oct 12 '16 at 17:56
  • yes...it is a modify header plugin where i set different headers which has to be added to all request. – Vishnu Oct 13 '16 at 05:11

0 Answers0