Cordova WP8LocalFileSystemURL solution doesn't work

Good afternoon, I have a cordova project that uses an image gallery and camera and stores images in a local cache folder. So I installed:

org.apache.cordova.camera 0.3.1 "Camera"
org.apache.cordova.file 1.3.1 "File"
org.apache.cordova.file-transfer 0.4.6 "File Transfer"

      

Android and iOS work great, but when it comes to WP8 (Windows Phone 8), the following code:

$scope.uploadImageFromPhone = function(isCamera){
        console.log('uploadImageFromPhone');

        var opt = {
            quality: 50,
            destinationType: Camera.DestinationType.FILE_URI,
            sourceType: (isCamera) ? Camera.PictureSourceType.CAMERA : Camera.PictureSourceType.PHOTOLIBRARY,
            encodingType: Camera.EncodingType.JPEG
        };

        function onGetImageSuccess(fileUrl) {
            console.log('onGetImageSuccess:\n'+fileUrl);
            window.resolveLocalFileSystemURL(fileUrl, resolveSuccess, resolveFails);
        }

        function onGetImageFail(message) {
            //console.log('onGetImageFailed:\n' + JSON.stringify(message));
        }

        function resolveSuccess (path) {
            console.log('resolveSuccess:');
            console.log(JSON.stringify(path));
            uri = path.nativeURL;

            //wp8 returns null as path.nativeURL
            /*IE10 specific hack*/
            if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
                uri = path.fullPath;
            }
        }

        function resolveFails(err){
            console.log('resolveFails:\n' + JSON.stringify(err));
        };

        navigator.camera.getPicture(onGetImageSuccess, onGetImageFail, opt); 
}

      

The resolveSuccess function always returns a path variable as shown below:

{"isFile":true,"isDirectory":false,"name":"wp_ss_20140923_0001.png","fullPath":"///CapturedImagesCache/wp_ss_20140923_0001.png","filesystem":"<FileSystem: temporary>","nativeURL":null}

      

The problem is that nativeURL is null.

According to my application, the selected file should be placed in the local application cache, so I am trying to load it and store it in the cache, approaching fullPath with the file transfer plugin:

var fileTransfer = new FileTransfer();
fileTransfer.download(
    uri, // equals to '///CapturedImagesCache/wp_ss_20140923_0001.png'
    'wp_ss_20140923_0001.png',
    function(entry){
        //file processing
        console.log('downloaded successfull');

    },
    function(error){
        console.log("download error" + JSON.stringify(error));
    },
    false,
    {}
);

      

This code always returns me console output:

download error: {"code":2,"source":"///CapturedImagesCache/wp_ss_20140923_0001.png","target":null,"http_status":null,"body":null,"exception":null}

      

I don't understand what am I doing wrong here? PS: cordova version: '3.6.3-0.2.13'

+3


source to share





All Articles