Trying to download a pdf doc from behind a secure REST API with Angular, we 
wrote this:

    var _config = { headers : {'Accept' : '*/*'},
                    responseType : 'arraybuffer'
                  };

    var success = function(data, status, header, config) {
       $log.debug('Download resume success - type:' + typeof (data));
       var _contentType = (header('Content-Type'));
       var blob = new Blob([ data ], { type : _contentType });
       var url = (window.URL || window.webkitURL).createObjectURL(blob);
       var anchor = angular.element('<a/>');
       anchor.attr({
          href : url,
          target : '_blank',
          download : _fileName
       })[0].click();
    }
    $http.get(_url, _config).success(success).error(error);

We've tried all permutations of blob and arraybuffer but `data` always 
returns as a String with the extended characters 'decoded' which is to say 
broken.

`_contentType` is always `application/pdf` although we've tried forcing it 
to `application/octet-stream` as well.

This seems pretty fundamental, what are we missing? (BTW we've tried 
FileSaver.js, didn't make any difference.)

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to