I have a problem when I create a FileReader (from @ionic-native/file) instance :
let f = new FileReader();
The following error occur :
TypeError: undefined is not a constructor (evaluating 'new __WEBPACK_IMPORTED_MODULE_2__ionic_native_file__["FileReader"]()')
I dont understand why !
My config is :
For more informations I use this code :
private readFile(file: any) {
const reader = new FileReader();
reader.onloadend = () => {
const formData = new FormData();
const imgBlob = new Blob([reader.result], {type: file.type});
formData.append('file', imgBlob, file.name);
this.postData(formData);
};
reader.readAsArrayBuffer(file);
}
An error occurs on new FileReader()
Thanks.
The Cordova polyfill saves the original FileReader in FileReader._realReader You can reassign it by doing:
let fr= new FileReader();
let rfr = fr._realReader;
FileReader = rfr.constructor;
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