resolveLocalFileSystemURI错误代码5 windows phone 7 phonegap

N0r*_*0rA 5 camera uri file windows-phone-7 cordova

我已经尝试过这项工作1. 捕获照片 2. 从它保存的地方获取照片 3. 以base64的形式阅读照片

我遵循了这种方法:

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);
}
Run Code Online (Sandbox Code Playgroud)

这条链工作正常,直到CameraSuccess然后它就失败了

window.resolveLocalFileSystemURI(imageURI, onResolveImageSuccess, onFail);
Run Code Online (Sandbox Code Playgroud)

它输入了onFail事件,错误代码= 5

顺便说一句,这个代码在Android上运行良好,但问题出现在Windows Phone 7,任何人都知道问题是什么?

DdD*_*DdD 4

我最近遇到了这个错误。解决方案很简单:)

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...
}
Run Code Online (Sandbox Code Playgroud)

如果您警告 imageURI,它应该看起来像 (/CachedImagePath/etcetc/),因此 window.resolveLocalFileSystemURI 不知道在哪里解析,因此通过在 URI 前面添加 // 它看起来在正确的路径中。

干杯,我会将这个问题发布到他们的错误跟踪器