ResolveLocalFileSystemURI error code 5 windows phone 7 phonegap

I tried to do this work 1. capture a photo 2. Get a picture from a saved location 3. Read the photo as base64

I followed this methodology:

var cameraOptions = {};
function capturePhoto() {
    console.log("capture photo");
    cameraOptions = { quality: 70, destinationType: Camera.DestinationType.FILE_URI, sourceType: Camera.PictureSourceType.CAMERA, saveToPhotoAlbum: true };
    doIt();
}
function doIt() {
    navigator.camera.getPicture(onCameraSuccess, onCameraFail, cameraOptions);
}
function onCameraSuccess(imageURI) {
    console.log("Camera Success");

    $('#MokhalfaPhotoLocation').val(imageURI);
    console.log("Image URI: " + imageURI);
    window.resolveLocalFileSystemURI(imageURI, onResolveImageSuccess, onFail); //get the file from the physical path...
}
  function onResolveImageSuccess(fileEntry) {
    fileEntry.file(gotFile, onFail);
}
function gotFile(file) {
    readDataUrl(file);
}
function readDataUrl(file) {
    console.log("read file as dataUrl");
    var reader = new FileReader();
    reader.onloadend = function (evt) {
        console.log("Read as data URL");
        window.localStorage.setItem("mokhalfaPhotoURL", evt.target.result);
 };
    reader.readAsDataURL(file);
}

this chain works fine until CameraSuccess fires on the line

window.resolveLocalFileSystemURI(imageURI, onResolveImageSuccess, onFail);

he introduced the onFail event with error code = 5

btw, this code worked fine on Android, but the problem is here in Windows Phone 7 does anyone know what the problem is?

+5
source share
3 answers

I recently ran into this error. The solution is pretty simple :)

function onCameraSuccess(imageURI) {
    console.log("Camera Success");

    $('#MokhalfaPhotoLocation').val(imageURI);
    console.log("Image URI: " + imageURI);
    window.resolveLocalFileSystemURI("//" + imageURI, onResolveImageSuccess, onFail); //get the file from the physical path...
}

imageURI, (/CachedImagePath/etcetc/), window.resolveLocalFileSystemURI , , URI// .

,

+4

. . " https://issues.apache.org/jira/browse/CB-2736". Windows 8 , HTML IMG. Entry.fullPath, fileEntry.toURL() fileEntry.toNativeURL().

0

you should try something like this

$window.resolveLocalFileSystemURL("file://" + videoURI, function (fileEntry) {
   console.log('Success: '+fileEntry.name);
   fileEntry.getMetadata(function(metadata) {
      if(metadata.size>20971520){
          $ionicPopup.alert({
              template: '<h5>Lo sentimos <i class="icon ion-sad-outline"></i> , el video sobre pasa el limite de peso</h5>',
              title: 'Limite de peso',
          });
       }else{

       }
    });
}, function (err) {
      console.log(err);
});
0
source

All Articles