2017-06-05 2 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]); 
関連する問題