Reputation: 487
I have some experience with meteorJS developing web apps but am just getting started with Cordova/hybrid app development. How would one access the android file system in a meteor app? Like if I wanted to display a list of pictures or media files on the device to the user in a meteor template, how could I get those files or the path to those files?
Upvotes: 0
Views: 869
Reputation: 487
Modifying the answer from List files inside www folder in PhoneGap for meteor:
if (Meteor.isCordova) {
Meteor.startup(function () {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
fileSystem.root.getDirectory("Download", {
create: true
}, function(directory) {
var directoryReader = directory.createReader();
directoryReader.readEntries(function(entries) {
var i;
for (i=0; i<entries.length; i++) {
console.log(entries[i].name);
var fileName = (entries[i].name);
var fullPath = (entries[i].fullPath);
var fileItem = {
name: fileName,
path: fullPath
};
Files.insert(fileItem); // inserts files into a mongo collection named "Files"
}
}, function (error) {
alert(error.code);
});
} );
}, function(error) {
alert("can't even get the file system: " + error.code);
});
});
}
Upvotes: 1