使用上有什么区别window.resolveLocalFileSystemURL
vs window.requestFileSystem
使用 cordova 文件插件下载文件时?我找不到有关resolveLocalFileSystemURL 的任何文档,但它工作正常,并且更易于使用?
我应该使用哪一个在 cordova 应用程序中进行简单的 CRUD 操作?
(我使用科尔多瓦3.4.0-0.1.3)
我这样使用它:
function onResolveSuccess(fileEntry) {
fileEntry.file(function(file) {
var reader = new FileReader();
reader.onloadend = function(evt) {
var _machines = JSON.parse(evt.target.result);
machinesCache.setMachines(_machines.AllMainCategories);
};
reader.readAsText(file);
}, errorHandler);
};
window.resolveLocalFileSystemURL("cdvfile://localhost/persistent/machinedata/machines.json", onResolveSuccess, errorHandler);
看着www/resolveLocalFileSystemURI.js
and www/requestFileSystem.js
in 文件插件存储库 https://github.com/apache/cordova-plugin-file/,我会说它们实际上是相同的。
我建议使用resolveLocalFileSystemURL
如果您想访问以下位置cordova.file.*
(eg cordova.file.dataDirectory
),这是大多数时间(如果不是总是),并使用requestFileSystem
如果您需要访问文件系统的根目录。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)