【发布时间】:2018-10-07 05:32:13
【问题描述】:
我的回复标题是:
HTTP/1.1 200 OK
Content-Disposition: attachment; filename="file.docx"
Accept-Ranges: bytes
Cache-Control: public, max-age=0
Last-Modified: Thu, 26 Apr 2018 10:37:00 GMT
ETag: W/"c61-16301871843"
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Content-Length: 3169
Date: Thu, 26 Apr 2018 10:37:00 GMT
Connection: keep-alive
我试过这段代码,
public download(id: string): Observable<Blob> {
let headers = new Headers();
const _baseUrl = (Api.getUrl(Api.URLS.download));
headers.append('x-access-token', this.auth.getCurrentUser().token);
headers.append('sale_id', id);
return this.http.get(_baseUrl, { headers: headers, responseType: ResponseContentType.Blob})
.map((res) => {
console.log(res.headers) // show like in image
return new Blob([res.blob()], { type: 'application/octet-stream' })
});
}
没有显示内容处置!!
如何从标题中获取文件名?
【问题讨论】:
标签: angular typescript http-headers blob