Trying to convet base64 from a remote url that is on rackspace cloud

49 Views Asked by At

Hi I am trying to convert a remote image from rackspace cloud files to base64 but getting loading mixed active content in console . I also tried it with Canvas but gets - " Cross origin issue" error in console Please suggest.

var url = "http://1ae2a3aafe30ce7168e4-04fc9e18e832cf1475b32d087b84e087.r95.cf1.rackcdn.com/caps/179_by_inopoke.jpg";
    var xmlHTTP = new XMLHttpRequest();
    xmlHTTP.open('GET', url, true);
    xmlHTTP.responseType = 'arraybuffer';
    xmlHTTP.onload = function(e) {
      var arr = new Uint8Array(this.response);
      var raw = String.fromCharCode.apply(null,arr);
      var b64 = base64.encode(raw);
      var dataURL="data:image/png;base64," + b64;
            console.log('res', dataURL);

    };
    xmlHTTP.send();
0

There are 0 best solutions below