Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(Phonegap + iOS) Why when I get the full path of the filesystem in a device or simulator I get only "/"?

Tags:

ios

cordova

Im running this simple code when the device ready is fired:

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs){

var imagesRootPath = fs.root.fullPath;
navigator.notification.alert(imagesRootPath);


},
function(evt) { navigator.notification.alert(evt.target.error.code)});

In a MAC pro with Phonegap 3.2 this works perfectly, when it code is running in the simulator, the imagesRootPath is a long string path. When I run this code deployed in a Ipod device, I get other different long path.

Now, when I run this code in a NOTEBOOK that has the same MacOS than the Mac Pro, but has Phonegap 3.3, I get in the simulator only "/" (slash) path and the same slash in when I deploy the Phonegap app on the device.

I made the proper plugin configuration for file API.

What may be wrong?

Thanks!

like image 898
Rahnzo Avatar asked Feb 13 '14 13:02

Rahnzo


4 Answers

In current plugin dev branch there is a solution:

Entry.toNativeURL() - Returns the full path to the file in the device FileSystem.

https://github.com/apache/cordova-plugin-file/tree/dev

like image 103
xudre Avatar answered Nov 16 '22 17:11

xudre


The latest release of Cordova changed the way the File plugin works with paths significantly. What you're seeing is actually the expected behaviour of the File plugin if you use the earlier documentation. (I was having the exact same problem with my older code).

http://cordova.apache.org/news/2014/02/10/plugins-release.html https://github.com/apache/cordova-plugin-file/blob/dev/doc/index.md - check out the upgrade notes.

like image 34
Chris Lloyd Avatar answered Nov 16 '22 19:11

Chris Lloyd


It's a shame this question was down voted because of its confusing explanation. I am having the same problem: fileEntry.fullPath returns '/fileName' instead of the actual file path. I see this behavior in versions 3.1 and 3.2 of phonegap as well.

Just so it's clear, by actual file path I mean something like: /Users/user/Library/Application Support/.../.../.../fileName'

like image 39
djtorres Avatar answered Nov 16 '22 18:11

djtorres


According to the doc:

If your application works with device-absolute-paths, and you previously retrieved those paths through the fullPath property of Entry objects, then you should update your code to use entry.toURL() instead.

like image 2
Can Geliş Avatar answered Nov 16 '22 19:11

Can Geliş