Phonegap file plugin- copy file from app package to persistent storage

删除回忆录丶 提交于 2020-01-14 06:32:16

问题


Issue: Using Phonegap on iOS I want to copy a image from the application package example

http://localhost/img/test.png

to the local persistent storage.

I'm ok getting the persistent storage via window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail). But how do I get the folder of the www root? Per file plugin docs I assume I somehow need to use cordova.file.applicationDirectory. Unfortunately the doc doesn't specify where/how to do that. I've tried some ways but no luck so far.

Any ideas?

Environment: -Phonegap 3.4 - org.apache.cordova.file plugin 1.1.0 (https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md) - iOS Simulator 7.1.


回答1:


Ok, figured it out now.

1) Upgrade plugin to 1.2.0 2) Use window.resolveLocalFileSystemURL

Example: window.resolveLocalFileSystemURL(cordova.file.applicationDirectory+'/www/img', function(dirEntry){...}, errorHandler);

As phonegap files are always below www don't forget that folder.




回答2:


Upgrade your org.apache.cordova.file to 1.2.0



来源:https://stackoverflow.com/questions/24067878/phonegap-file-plugin-copy-file-from-app-package-to-persistent-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!