Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to intercept angular-file-upload module file upload requests using http interceptor

the HTTP interceptor not intercepting the file upload calls from the nervgh/angular-file-upload , how can intercept those calls.

I am adding HTTP authentication Headers to all my api calls, But these angular file upload calls are not intercepted and authentication headers are not added to these calls.

like image 824
Dhanesh H S Avatar asked Sep 12 '26 01:09

Dhanesh H S


1 Answers

It may be because the up-loader doesn't use the $http service.

It uses native javascript xhr object. Maybe in the future the $http service will be supported. For now, you'll have to add the authorization headers in the up-loader directly:

var uploader = new FileUploader();
uploader.headers["Authorization"] = "Bearer " + tokenInfo.accessToken;
like image 173
Hemdip Avatar answered Sep 14 '26 14:09

Hemdip



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!