0

我正在使用使用 cordova 作为平台的 mobilefirst/worklight 应用程序。我之前的应用程序是在使用cordova 3.1 版的移动优先6.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 一样。

文件系统中是否有任何方法返回我可以从其他应用程序访问的路径?它也应该适用于ios。

4

1 回答 1

1

我在这里找到了解决方案:https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/

我可以使用 cordova.file.externalRootDirectory 而不是 fileSys.root.toURL()。

于 2016-11-02T07:53:20.130 回答