I am trying to implement a simple user signup where user has the option to upload a profile image. I am using ionic native crop plugin to crop the image this returns a uri that i am going to use to read the file from cache directory using native file plugin. Now the problem is that file.readAsDataURL() method return a file not found error. Here is my code.
addFromGallery(){
this.camera.getPicture(this.galleryOptions)
.then((fileUri) => {
// Modify fileUri format, may not always be necessary
fileUri = 'file://' + fileUri;
/* Using cordova-plugin-crop starts here */
return this.crop.crop(fileUri, { quality: 100 });
}).then((path) => {
this.file.readAsDataURL(this.file.cacheDirectory, "a.txt")
.then(function (success) {
console.log("SUCESS", success);
// success
}, function (error) {
console.log('ERROR', error);
// error
});
})
}
I have consoled this.file.cacheDirectory it returns the correct path where a.txt is located. but it still gives me the error.
This is my this.file.cacheDirectory returns “file:///storage/emulated/0/Android/data/com.ionicframework.myapp191974/cache/”
I am testing on a real device running Android Nougat.