【问题标题】:How to access android file system in a meteor app?如何在流星应用程序中访问 android 文件系统?
【发布时间】:2015-01-11 00:23:28
【问题描述】:

我有一些使用 meteorJS 开发 Web 应用程序的经验,但我才刚刚开始使用 Cordova/混合应用程序开发。如何在流星应用程序中访问 android 文件系统? 例如,如果我想在流星模板中向用户显示设备上的图片或媒体文件列表,我该如何获取这些文件或这些文件的路径?

【问题讨论】:

标签: android cordova meteor


【解决方案1】:

List files inside www folder in PhoneGap 修改为流星的答案:

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);
    });
});

}

【讨论】:

  • 这将获取图像元数据,如文件名和路径,但我无法加载实际图像。我尝试将路径放入 ,但图像无法加载。
猜你喜欢
  • 2013-03-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-25
  • 2016-02-18
  • 1970-01-01
相关资源
最近更新 更多