Cordova 3.6 正在返回应用程序特定的数据路径而不是外部可访问路径
Cordova 3.6 is returning application specific data path instead of external accessible path
我正在使用使用 cordova 作为平台的 mobilefirst/worklight 应用程序。我以前的应用程序是移动优先 6.1,它使用 cordova 3.1 版。现在我正在将我的应用程序升级到使用 cordova 3.6 版的 mobilefirst 7.1(从 worklight 重命名)。
对于文件系统访问,我正在使用
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys){
var path = fileSys.root.fullPath;
//Output : file://storage/emulated/0 <-- Cordova 3.1 For Android
//Output : / <-- Cordova 3.6 For Android
});
由于cordova在3.3版本之后改变了结构,我将fullPath改为toURL();
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys){
var path = fileSys.root.toURL();
//Output : file://data/0/com.MyApp/files/files <-- Cordova 3.6 For Android
});
这里的问题是它给我一个应用程序的数据路径。我正在存储应该可以从外部访问的数据,就像之前的 -file://storage/emulated/0。
文件系统中是否有任何方法 returns 我可以从其他应用程序访问路径?它也应该适用于 ios。
我在这里找到了解决方案:https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/
我可以使用 cordova.file.externalRootDirectory 而不是 fileSys.root.toURL()。
我正在使用使用 cordova 作为平台的 mobilefirst/worklight 应用程序。我以前的应用程序是移动优先 6.1,它使用 cordova 3.1 版。现在我正在将我的应用程序升级到使用 cordova 3.6 版的 mobilefirst 7.1(从 worklight 重命名)。
对于文件系统访问,我正在使用
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys){
var path = fileSys.root.fullPath;
//Output : file://storage/emulated/0 <-- Cordova 3.1 For Android
//Output : / <-- Cordova 3.6 For Android
});
由于cordova在3.3版本之后改变了结构,我将fullPath改为toURL();
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys){
var path = fileSys.root.toURL();
//Output : file://data/0/com.MyApp/files/files <-- Cordova 3.6 For Android
});
这里的问题是它给我一个应用程序的数据路径。我正在存储应该可以从外部访问的数据,就像之前的 -file://storage/emulated/0。
文件系统中是否有任何方法 returns 我可以从其他应用程序访问路径?它也应该适用于 ios。
我在这里找到了解决方案:https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/
我可以使用 cordova.file.externalRootDirectory 而不是 fileSys.root.toURL()。