Add Secure image authorization header?

I’m using Ionic 1.0.0 and have a auth $httpProvider.interceptor setup which works fine for all secure XHR requests after logging in.

However this does not seem to intercept any requests and add the required Authorization header through config.headers.

Is there a mechanism to intercept the image requests and add an authorization header ?

Thanks for any help.

Try this

app.directive(‘httpSrc’, [
‘$http’, function ($http) {
var directive = {
link: link,
restrict: ‘A’
};
return directive;
function link(scope, element, attrs) {
var requestConfig = {
method: ‘Get’,
url: attrs.httpSrc,
responseType: ‘arraybuffer’,
cache: ‘true’
};

            $http(requestConfig)
                .success(function(data) {
                    var arr = new Uint8Array(data);

                    var raw = '';
                    var i, j, subArray, chunk = 5000;
                    for (i = 0, j = arr.length; i < j; i += chunk) {
                        subArray = arr.subarray(i, i + chunk);
                        raw += String.fromCharCode.apply(null, subArray);
                    }

                    var b64 = btoa(raw);

                    attrs.$set('src', "data:image/jpeg;base64," + b64);
                });
        }

    }
]);

Ref: angularjs - Force HTTP interceptor in dynamic ngSrc request - Stack Overflow

Yes that does work.

Just have to workout how to force a image refresh in the view since its a dynamically updated image on the server.