angularhttp-headersinterceptorangular-http-interceptorsangular-file-upload

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.


Solution

  • 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;