0

我正在使用使用cordova作为平台的mobilefirst/worklight应用程序。我以前的应用程序是使用cordova 3.1版的移动版6.1。现在我正在将我的应用程序升级到使用cordova 3.6版的mobilefirst 7.1(从worklight更名)。Cordova 3.6正在返回特定于应用程序的数据路径,而不是外部可访问路径

对于文件系统的访问,我使用

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

作为科尔多瓦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上工作。

回答

1

我发现在这里的解决方案:https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/

我可以用cordova.file.externalRootDirectory代替fileSys.root.toURL()。

相关问题