I am following this guide on how to upload an image file using Ionic 3 on an iPhone Simulator. However I am stuck at this error printed from console
{"code":5,"message":"ENCODING_ERR"}
The code is as follows:
this.file.resolveLocalFilesystemUrl(dto.image)
.then((entry: FileEntry) => entry.file(file => {
const reader = new FileReader();
reader.onloadend = () => {
//do something
};
reader.readAsArrayBuffer(file);
}))
.catch(err => console.log(JSON.stringify(err)));
the value of dto.image is:
/Users/myUsername/Library/Developer/CoreSimulator/Devices/05972D1E-F805-46E4-B164-BB95F116697A/data/Containers/Data/Application/1096409B-6FA3-4660-97AE-EAF3E2472046/tmp/cdv_photo_013.jpg
I am using ionic native File plugin
Thanks in advance.
seems stupid but this is the solution:
append file:// at the start of the url string so it would work.
so the start will be like file:///Users....
This is not documented but i have guessed from this link
cordova ios resolveLocalFileSystemURL ENCODING_ERR in cordova.file.applicationDirectory
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