如何知道Angular 2中blob文件的类型?
服务器发送blob文件,可以是PDF或图像文件,如何知道blob中是什么,是图像还是PDF 现在,我只需要获取这个blob文件并设置内容类型:application/pdf或image/jpg 我的服务:如何知道Angular 2中blob文件的类型?,angular,typescript,Angular,Typescript,服务器发送blob文件,可以是PDF或图像文件,如何知道blob中是什么,是图像还是PDF 现在,我只需要获取这个blob文件并设置内容类型:application/pdf或image/jpg 我的服务: downloadPDF(fileId: string): Observable<Blob> { var header = new HttpHeaders(); header.append('Accept', 'application/octet-stream'); re
downloadPDF(fileId: string): Observable<Blob> {
var header = new HttpHeaders();
header.append('Accept', 'application/octet-stream');
return this._http.get(this._api.powerLoadApi.getFileLink(this.WellId,
fileId), {
headers: header,
responseType: 'blob',
})
.map(res => {
return new Blob([res], { type: "application/pdf"} );
});
}
downloadPDF(fileId:string):可观察{
var header=新的HttpHeaders();
header.append('Accept','application/octet stream');
返回此,
文件ID){
标题:标题,
responseType:'blob',
})
.map(res=>{
返回新的Blob([res],{type:“application/pdf”});
});
}
说使用FileReader,但我认为它与其他浏览器有问题