Can anybody tell me why IE11 is throwing error at the last line -
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 });
This is working in both Chrome and Firefox.IE throws object error -
Object doesn't support this action.
Files are Blobs plus meta properties, so you can just add the necessary properties like this :
let blob = this.documentService.base64toBytes(this.document.documentBlob.documentData, this.document.documentDataFormat);
// and add the meta properties
blob['lastModifiedDate'] = new Date();
blob['name'] = 'fileName';
Then the blob is a file.
As IE does not support constructor of File API, I have come up with the following workaround. Hope this helps to others in future -
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]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With