1

I’m currently working on a ionic/cordova application developed with angularJS. I need to include an image provided by a secured API requiring an HTTP authorization in a template and can’t find a way to make it work. The API returns the jpeg with the appropriate response headers.

Here is the way my app calls the image :

 $http(req).
        then(function (data, status, headers, config) {
             return data;

  });

I tried to insert the « code » of this jpeg in a src/ng-src/data-ng-src with a base64 reencoded string (or not) and even tried to convert it in a Blob in order to use the FileReader(); I also made an attempt to sanitize it with $compileProvider.imgSrcSanitizationWhitelist(/^\s(https|file|blob|cdvfile|content):|data:image\//);

None of these solutions worked !

Thanks Thanks

  • 1
    What is the format in which you receive this file? – T J Apr 13 '16 at 12:32
  • Can you provide an exemple of "api" or something similar? I try with some other websites but I only get `"No 'Access-Control-Allow-Origin' header is present on the requested resource.` bla bla bla... – Patrick Ferreira Apr 13 '16 at 12:43
  • have you tried with ng-scr="data:image/jpeg;base64" http://stackoverflow.com/questions/28235246/angularjs-display-base64-image – Groben Apr 13 '16 at 12:47
  • I receive the file in JPEG, and yes I tried the "data:..." – Dimitri Mathot Apr 13 '16 at 15:09
  • The Api I use is a personnal API developped at my job by someone else, and he prefers to send back a JPEG rather than a base64 file. – Dimitri Mathot Apr 13 '16 at 15:11

0 Answers0