我想从
Content-Disposition
这是我的代码:
public getQuoteImage(sharedQuote):Observable<any> {
return this.http.post(environment.downloadSummarUrl, JSON.stringify(sharedQuote), {
headers: this.params.headers.validate,
observe: "response",
responseType : 'blob'
});
}
我想得到
filename
内容处理
downloadSummaryContent() {
this.server.getQuoteImage(this.sharedQuote).subscribe((data) => {
console.log( 'headers are', '\n', data, '\n', data.headers.get('Content-Disposition') ); //but not getting the file name
var url = window.URL.createObjectURL(data);
var a = document.createElement('a');
document.body.appendChild(a);
a.setAttribute('style', 'display: none');
a.href = url;
a.download = 'quote.pdf';
a.click();
window.URL.revokeObjectURL(url);
a.remove(); // remove the element
});
}
但根本没有得到价值。
{
"headers": {
"normalizedNames": {
},
"lazyUpdate": null,
"lazyInit": null,
"headers": {
}
},
"status": 200,
"statusText": "OK",
"url": "https:XXXXXXservice/p/shipment/download/",
"ok": true,
"type": 4,
"body": {
}
}