I m trying to get the image from the gallery or the camera of android as fileURI and then convert it into File Using resolveLocalFilesystemUrl
const options: CameraOptions = {
quality: 100,
correctOrientation: true,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
sourceType: sourceType
}
and then:
// Get the picture
this.camera.getPicture(options).then((imageData) => {
console.log("now here !");
console.log(imageData);
the imageData I’m getting is:
file:///storage/emulated/0/Android/data/io.ionic.app5/cache/IMG-20180802-WA0004.jpg?1533286934006
the error I’m getting is at " this.file.resolveLocalFilesystemUrl(imageData) "
let loading = this.loadingCtrl.create();
loading.present();
console.log(imageData);
// Resolve the picture URI to a file
this.file.resolveLocalFilesystemUrl(imageData).then(oneFile => {
// Convert the File to an ArrayBuffer for upload
this.file.readAsArrayBuffer(this.file.tempDirectory, oneFile.name).then(realFile => {
let type = 'jpg';
let newName = this.awsProvider.randomString(6) + new Date().getTime() + '.' + type;
And the ERROR is:
cordova.js:422 Wrong type for parameter "uri" of resolveLocalFileSystemURI: Expected String but got Null.