2017-06-05 84 views
1

谁能告诉我,为什么IE11在最后一行抛出错误 -IE 11未能创建从字节数组文件对象角2

this.document = this.control.value; 
    const bytes = 
this.documentService.base64toBytes(this.document.documentBlob.documentData, 
     this.document.documentDataFormat); 
const file = new File(bytes, this.document.documentName, { type: 
     this.document.documentDataFormat }); 

这在Chrome和Firefox.IE工作抛出对象错误 -

Object doesn't support this action. 
+1

IE11似乎并不支持每http://caniuse.com/#search=file – silentsod

+0

哎呀文件构造!什么建议然后作为解决方法? – Mayeed

回答

1

由于IE不支持File API的构造函数,所以我想出了以下解决方法。希望这有助于他人在未来的 -

const bytes = this.documentService.base64toBytes(this.document.documentBlob.documentData, this.document.documentDataFormat); 
let file: File; 
try { 
    file = new File(bytes, this.document.documentName, { type: this.document.documentDataFormat }); 

    if (this.uploader.isFile(file)) { 
    this.uploader.addToQueue([file]); 
    } 
} catch (err) { // Workaround for IE 11 
    const blob = this.documentService.base64ToBlob(this.document.documentBlob.documentData, 
    this.document.documentDataFormat); 
    file = this.documentService.blobToFile(blob, this.document.documentName); 
    this.uploader.addToQueue([file]);