Skip to content

Commit

Permalink
Enable reading files from the assets directory.
Browse files Browse the repository at this point in the history
The cdvfile scheme allows access to defined filesystems, but before this
commit, it wasn't possible to read files from application's assets folder.

An example URL to access the cordova.js file would be:
cdvfile://localhost/assets/www/cordova.js
  • Loading branch information
vjrantal committed Sep 24, 2015
1 parent 5f88e01 commit caf90a2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ Android recognize a <preference> tag in `config.xml` which names the
filesystems to be installed. By default, all file-system roots are enabled.
<preference name="iosExtraFilesystems" value="library,library-nosync,documents,documents-nosync,cache,bundle,root" />
<preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,root" />
<preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,root,assets" />
### Android
Expand All @@ -506,6 +506,7 @@ filesystems to be installed. By default, all file-system roots are enabled.
* `cache`: The application's internal cache directory
* `cache-external`: The application's external cache directory
* `root`: The entire device filesystem
* `assets`: The application's assets directory
Android also supports a special filesystem named "documents", which represents a "/Documents/" subdirectory within the "files" filesystem.
Expand Down
2 changes: 1 addition & 1 deletion src/android/AssetFilesystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ long truncateFileAtURL(LocalFilesystemURL inputURL, long size) throws IOExceptio

@Override
String filesystemPathForURL(LocalFilesystemURL url) {
return null;
return toNativeUri(url).getPath();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3632,7 +3632,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
var fsRoots = {
"ios" : "library,library-nosync,documents,documents-nosync,cache,bundle,root,private",
"osx" : "library,library-nosync,documents,documents-nosync,cache,bundle,root,private",
"android" : "files,files-external,documents,sdcard,cache,cache-external,root",
"android" : "files,files-external,documents,sdcard,cache,cache-external,root,assets",
"amazon-fireos" : "files,files-external,documents,sdcard,cache,cache-external,root",
"windows": "temporary,persistent"
};
Expand Down

0 comments on commit caf90a2

Please sign in to comment.