You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Shravan Narayan (JIRA)" <ji...@apache.org> on 2013/05/06 18:16:16 UTC

[jira] [Comment Edited] (CB-285) Add property returning root path of PhoneGap files

    [ https://issues.apache.org/jira/browse/CB-285?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13649818#comment-13649818 ] 

Shravan Narayan edited comment on CB-285 at 5/6/13 4:14 PM:
------------------------------------------------------------

Went through the data for a few more the platforms' file storage requirements
android: http://developer.android.com/guide/topics/data/data-storage.html
ios: http://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/FileSystemProgrammingGUide/FileSystemOverview/FileSystemOverview.html
windows phone: http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff402541(v=vs.105).aspx
blackberry: https://developer.blackberry.com/cascades/documentation/device_platform/filesystem/index.html
tizen: https://developer.tizen.org/help/index.jsp?topic=%2Forg.tizen.native.appprogramming%2Fhtml%2Fbasics_tizen_programming%2Fio_overview.htm

No major surprises except, that the sd card on windows phone is read only (also it requires you to specify which extensions you want, but that may or may not be pertinent here)
Thus I suggest that we add a needWritableAccess flag to the api. Because of this, I don't think we need a separate api for the app directory

So I would like to suggest that the api be 
cordova.file.getDirectoryForPurpose({
  optional boolean needWritableAccess = true,
  optional boolean sandboxed = true,
  optional LocalFileSystem.Category category = LocalFileSystem.Category.DATA,
  optional LocalFileSystem.Persistance persistance = LocalFileSystem.Persistance.PERSISTANT - up for debate
}, function callback(location){
   if(location)
        // Success
});

If we try to access the sd card on windows phone(by specifying not sandboxed) with write access, revert to a special directory in internal storage like '/saved_sd_card_content' and while reading from sd card check if file exists here first before checking the sd card.

LocalFileSystem.Category
{
  // AT LEAST NEED
  APP, DATA, DOCUMENTS,
  // LATER ALSO NEED
  IMAGES, DOCS, VIDEO, AUDIO etc. etc. (need a better summary of platform specific categorizations of files)  
}
APP - the app bundle such as file:///android_asset
If we try to access APP with writeAccess throw an exception.

LocalFileSystem.Persistance
{
  TEMPORARY, CACHE, PERSISTANT, DEVICE_PERSISTANT, CLOUD
}

Note: DEVICE_PERSISTANT vs CLOUD
DEVICE_PERSISTANT - store files with syncing such as iCloud on ios enabled, however this is device specific
CLOUD - store files with syncing such as dropbox on blackberry enabled, however this is may be the same across devices

Blackberry can implement the DEVICE_PERSISTANT option by storing data in a folder such as "/Cordova_Device_Data/MY_DEVICE_NAME/" to maintain a saparation across devices.
                
      was (Author: shravanrn):
    Went through the data for a few more the platforms' file storage requirements
android: http://developer.android.com/guide/topics/data/data-storage.html
ios: http://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/FileSystemProgrammingGUide/FileSystemOverview/FileSystemOverview.html
windows phone: http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff402541(v=vs.105).aspx
blackberry: https://developer.blackberry.com/cascades/documentation/device_platform/filesystem/index.html
tizen: https://developer.tizen.org/help/index.jsp?topic=%2Forg.tizen.native.appprogramming%2Fhtml%2Fbasics_tizen_programming%2Fio_overview.htm

No major surprises except, that the sd card on windows phone is read only (also it requires you to specify which extensions you want, but that may or may not be pertinent here)
Also now I don't think we need a separate api for the app directory

So I would like to suggest that the api be 
cordova.file.getDirectoryForPurpose({
  optional boolean needWritableAccess = false,
  optional boolean sandboxed = true,
  optional LocalFileSystem.Category category = LocalFileSystem.Category.DATA,
  optional LocalFileSystem.Persistance persistance = LocalFileSystem.Persistance.PERSISTANT - up for debate
}, function callback(location){
   if(location)
        // Success
});


LocalFileSystem.Category
{
  // AT LEAST NEED
  DATA, DOCUMENTS,
  // LATER ALSO NEED
  IMAGES, DOCS, VIDEO, AUDIO etc. etc. (need a better summary of platform specific categorizations of files)  
}
LocalFileSystem.Persistance
{
  TEMPORARY, CACHE, PERSISTANT, DEVICE_PERSISTANT, CLOUD
}

Note: DEVICE_PERSISTANT vs CLOUD
DEVICE_PERSISTANT - store files with syncing such as iCloud on ios enabled, however this is device specific
CLOUD - store files with syncing such as dropbox on blackberry enabled, however this is may be the same across devices

Blackberry can implement the DEVICE_PERSISTANT option by storing data in a folder such as "/Cordova_Device_Data/MY_DEVICE_NAME/" to maintain a saparation across devices.
                  
> Add property returning root path of PhoneGap files
> --------------------------------------------------
>
>                 Key: CB-285
>                 URL: https://issues.apache.org/jira/browse/CB-285
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: CordovaJS
>    Affects Versions: 1.4.0
>         Environment: Both PhoneGap SDK and PhoneGap Build
>            Reporter: Ashley Gullen
>            Assignee: Andrew Grieve
>              Labels: features
>
> There needs to be a property in PhoneGap that returns the root path to the general files added to the PhoneGap project (i.e. the directory index.html is in).  For example, if I add 'music.mp3' to my project, in Android it will be located in:
> /android_asset/www/music.mp3
> On iOS after being built with PhoneGap Build it will be located in some path like this:
> /var/mobile/Applications/<app_ID>/<name>.app/www/music.mp3
> However, there does not appear to be a programmatic way to determine both <app_ID> and <name>.app.
> This has two side effects:
> 1. Paths to audio for Media must be hard-coded separately depending on the platform, which is inconvenient.
> 2. Paths to audio for Media cannot be known if developing a framework that uses PhoneGap.  Since a framework does not know the App ID or name in advance, it's impossible for the framework to determine the correct path.
> This is actively blocking audio from working on iOS in PhoneGap projects exported by Construct 2 (www.scirra.com), a HTML5 game creator.  Also, it seems like kind of an important function to make available anyway, since hard-coding paths for each platform is a pain.
> This PhoneGap Support thread led to this issue: http://phonegap.tenderapp.com/discussions/questions/208-android_asset-equivalent-for-ios

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira