Start a new topic

Cordova File Paths

Cordova File Paths


Cordova/Phonegap has changed the way it stores file paths so your no longer get the full system file:// uri. Instead they now implement a cdvfile:// uri to pass file locations through javascript.

When using Entry.fullPath it now only returns a path from the route of the assets folder and not a filesystem path to the persistent file location. You have to use the Entry.toURL() method, however this returns an cdvfile://localhost/persisten/path/to/file url.

Are there any plans for the Wikitude phonegap plugin to be updated to support the new file urls provided by the cordova filesystem api? Or is this already implemented and the reason for the ARchitect world not loading is something else?

https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md#upgrading-notes

Hi Mikey,
The Wikitude Plugin does not handle cdvfile:// urls. 
Have you tried using the resolveLocalFileSystemURL function to get the absolute file path representation?
You could also try to find a plugin which somehow returns the applications path (/var/mobile/Applications/<application UUID>) and manually append the /path/to/file which is returned by the 'Entry'.

If none of these possibilities is working for you, you could change the Wikitude Plugin implementation but this would require some ObjC and iOS SDK understanding.
 

Best regards

Andreas

Hi, I found a function within phonegap to get the full root url /var/mobile/Applications/<UUID>/path/to/file etc (.toNativeURL()) however Wikitude still can't seem to use this path?

I've manged to get it working by running WikitudePlugin.loadARchitectWorld("../Library/files/path/to/file"); on iOS.

I still need to test on Android to see what I need to do on that platform, however thought the above may help anyone else having problems.

Cheers

Mikey

Hi,
The iOS path with */Library/files/* seems a little bit odd to me. You can simply pass in a relative path (root is the www folder). Please have a look at our sample application for PhoneGap which handles both platforms using relative paths. We have a PhoneGap Documentation on our website which describes in detail how to use the Plugin and how to setup the Sample Application. 

Best regards

Andreas

Hi Andreas,

I've been through your documentation and had this working before ... it was only in the updated version that I've had to change the code.

The fact that Wikitude uses a relative path to the www folder is why the ../Library/files filepath works. To enable us to update the world without having to resubmit the app each time (and without the user having to download it everytime they use the app) I have made the app download and store the world in persistent storage. When the user opens the app it will check for an updated World folder on our servers and download it if it exists. This means that the world folder is not stored within the www folder but outside of it.

On iOS the persistent files are saved to the Library/files folder (within the application folder, hence the file location above). I just need to double check were android saves the files to and then update the file path accordinly.

Hope this clears up some of the confusion :)

Hi Mikey,
Thanks for the detailed explanation. It's always good to know as much as possible about the project/app to give you the best support.
Please ping us if you need help for Android and I will forward this thread to our Android support team.

Best regards

Andreas
Login or Signup to post a comment