Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70432

window.resolveLocalFileSystemURL is not a function error

$
0
0

@vaishali123 wrote:

I am working on an app where the user’s picture captured through the camera is to be sent to the microsoft face api for face detection. I am trying to do this by converting the image into blob and then sending the blob object as data in the post request. However, I am not able to convert the image into blob. Here is the code I am using for the conversion:

onClickPicture(){

this.camera.getPicture({
quality: 100,
destinationType: this.camera.DestinationType.NATIVE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
saveToPhotoAlbum: true
}).then((_imagePath) => {

  alert('got image path ' + _imagePath);
  return this.makeFileIntoBlob(_imagePath); }).then((_imageBlob) => {
alert('got image blob ' + _imageBlob);
this.detectFace(_imageBlob);
  },(err) => {
    alert(err);
  });

}

makeFileIntoBlob(_imagePath) {

return new Promise((resolve, reject) => {
ionic.Platform.ready().then( () => {
alert(“platform ready”);
window.resolveLocalFileSystemURL(_imagePath, (fileEntry) => {
alert(“inside resolve local file system url.”);
fileEntry.file((resFile) => {
var reader = new FileReader();
reader.onloadend = (evt: any) => {
var imgBlob: any = new Blob([evt.target.result], { type: ‘image/jpeg’ });
imgBlob.name = ‘sample.jpg’;
resolve(imgBlob);
};

    reader.onerror = (e) => {
      console.log('Failed file read: ' + e.toString());
      reject(e);
    };

    reader.readAsArrayBuffer(resFile);
  });
});

});
});
}

The code gives me a window.resolveLocalFileSystemURL is not a function error while testing with an image on browser. I am using ionic-native/file for this. I have tried a few things like - adding “AndroidExtraFilesystems” tag to config.xml , switched to npm version 5.0.3. But, I am not able to figure out the cause of the error. While, testing it on android device, neither I am getting any error nor is the app getting stuck. It just doesn’t give any alert after the makeFileIntoBlob function is called. I am stuck on it for days now. Any help is highly appreciated.

Thanks.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70432

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>