Ionic-native file, readAsArrayBuffer throws Encoding error when file is on SDCard


#1

Hi there,

In my mobile app, I’m trying to read a saved file on the external storage using the following code

return fromPromise(this.file.readAsArrayBuffer(path, fileName)).catch(error =>
{
console.log (JSON.stringify(error);
});

but I keep getting encoding error, code 5.

the path is :

/storage/36BA-13E6/Android/data/myApplicationPackageName/files/0815e16b-6048-4111-8f36-659f4f24b476/books/31-00117-17/

file Name is :

“myFile.json”

resulting error is

“{“code”:5,“message”:“ENCODING_ERR”}”

I’ve tried to prepend “file:///” to the path as mentioned in some forums but it didn’t work.
To note that when saving file on the internal storage I don’t get this error, and I get the same error when trying to remove file

return fromPromise(this.file.removeFile(savePath, fileName)).catch(error => {
return Observable.of({
success: false,
fileRemoved: null
});
});

My application has storage permissions granted.

Can anyone advise please?

Thank you in advance!