1

I'm building an app which should download a file from a server and save it "in the app". I'm using FileTransfer for this. Now I want to ask if it's possible to save the file in my "www" folder? If not, where should I save this file?

I tried it with fileSystem.root.fullPath, but where is the "www" folder in ios?

thank you!

Emanuel
  • 41
  • 1
  • 3

1 Answers1

0

The application directory contains the www folder of your app. However, that location is read only, so you won't be able to store your data in there. For storage, the file system root is a good choice. On ios, it correspond to the Documents directory, which is persistent read/write storage, i think it suits most app's needs. I'll still show how to access the application folder in case you're interested on accessing some files there.


When using the file plugin, you can access iOS's application inner folders using the cordova.file.applicationDirectory location (for other iOS locations, check out the table at https://github.com/apache/cordova-plugin-file#ios-file-system-layout). Use it with resolveLocalFileSystemURI, and it'll give a directory entry at said location to its success callback.

From there you can then access the www folder by using getDirectory.

Short Example

window.resolveLocalFileSystemURI(cordova.file.applicationDirectory,
    function(appDirectory) {
         appDirectory.getDirectory("www", {create:false}, onSuccess, onFailure);
    }, 
onFailure);
Bettorun
  • 227
  • 1
  • 3
  • 8