inf*_*dev 5 javascript pdf firefox blob typescript
我将打开在Firefox上从服务器发送的文件。
实际上,它正在IE上运行。这是我的操作方法。
openFile(path, fileName) {
this.creditPoliciesService
.openFile(path)
.toPromise()
.then(data => {
var blob = new Blob([data.body], { type: "application/pdf" });
if (window.navigator && window.navigator.msSaveOrOpenBlob) { //if navigator is IE
window.navigator.msSaveOrOpenBlob(blob, fileName);
} else { // Mozilla case
var fileURL = URL.createObjectURL(blob); //URL.createObjectURL takes only one parameter.
window.open(fileURL);
}
});
}
Run Code Online (Sandbox Code Playgroud)
当我打开文件时,我在新标签页中看到blob:http://localhost:4200/90907276-947a-47d8-873d-40163
一个空白页面的Blob地址
我想我应该传递文件名,但是用 URL.createObjectURL
如何打开正确格式的文件?
编辑:
归档时间: |
|
查看次数: |
1523 次 |
最近记录: |