How to receive blob responses using Angular's 2+ @angular/http module?

后端 未结 3 1395
暖寄归人
暖寄归人 2020-12-02 16:09

I\'m trying to provide a pdf download from within an angular 2 app...

this code works:

    var reportPost = \'variable=lsdkjf\';

    var xhr = new X         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 16:21

    See here: https://stackoverflow.com/a/45666313/4420532

    return this._http.get('/api/images/' + _id, {responseType: 'blob'}).map(blob => {
      var urlCreator = window.URL;
      return this._sanitizer.bypassSecurityTrustUrl(urlCreator.createObjectURL(blob));
    })
    

提交回复
热议问题