Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova resolveLocalFileSystemURL success call back failing on iOS

Tags:

ios

cordova

I've just created a new project and installed the file and file-transfer api's via CLI. I have already created a working app previously so I know how to use phonegap and have been doing so for a few years now.

Here is the code:

window.resolveLocalFileSystemURL("file:///localhost/var/mobile/Applications/96B4705C-C70D-4340-9A42-HJ1F28355D43/tmp/cdv_photo_015.jpg", function(fileEntry){
        console.log(fileEntry.name);
    }, function(error){
     console.log('about to resolve this files errors');
        console.log(error.code);
    });

Nothing ever gets outputted in the console debugging window ...and yes I have debug installed cause I have console.log() in other parts of my code that show up.

It seems like there is an issue when passing URL data from navigator.camera.getPicture() to the file API when using window.resolveLocalFileSystemURL()...any ideas anyone. I'm up to date on phonegap api and everything and I have this issue for the past few days now...I can't seem to solve it.

***EDIT***

Seems like when you use Camera.DestinationType.FILE_URI as a parameter for navigator.camera.getPicture(). When you choose a picture and the success call back for navigator.camera.getPicture() is triggered, trying to window.resolveLocalFileSystemURL from the URL that getPicture returns just fails. But if you set Camera.DestinationType.NATIVE_URI it at least returns something but it's in a format that can't be used with the file-transfer api exp: assets-library://asset/asset.JPG?id=220BCEAE-F1EA-4A6A-83B2-AB8833A90BF2&ext=JPG

like image 486
greaterKing Avatar asked Feb 24 '14 06:02

greaterKing


1 Answers

Seems like this was a bug in the file api v1.0.0

https://issues.apache.org/jira/browse/CB-6116

Temp solution is there as well.

Seems like "/local/" was causing the issue. Remove it from incoming uri's if it exist and the resolve should work.

like image 86
greaterKing Avatar answered Sep 18 '22 13:09

greaterKing