Joh*_*ohn 12 pdf blob asp.net-core angular
我正在尝试将从服务器生成的PDF显示在我的Angular 2 RC 5项目中的视图上.现在,ASPNETCORE服务器将对象作为'application/pdf'返回,Angular客户端正在尝试将响应解析为blob.但是,我在客户端收到以下错误:
Error: The request body isn't either a blob or an array buffer
我用来调用PDF服务器的代码基本上是:
getHeaders() : Headers {
var headers = new Headers({
'responseType': 'application/blob'
});
return headers;
}
getBlob() {
return this.http.get(uri, new RequestOptions({headers: this.getHeaders()}, body: "" }))
.map(response => (<Response>response).blob());
}
Run Code Online (Sandbox Code Playgroud)
fle*_*ske 23
尝试将responseType设置为Blob,它应该工作:
getBlob() {
return this.http.get(uri, {responseType: ResponseContentType.Blob})
.map(response => (<Response>response).blob());
Run Code Online (Sandbox Code Playgroud)
}
| 归档时间: |
|
| 查看次数: |
8187 次 |
| 最近记录: |