Phonegap文件插件 - 将文件从应用程序包复制到持久性存储 [英] Phonegap file plugin- copy file from app package to persistent storage
问题描述
在iOS上使用Phonegap我想从应用程序包复制一个图像示例
http: //localhost/img/test.png
到本地永久性存储。
通过 window.requestFileSystem(LocalFileSystem.PERSISTENT,0,gotFS,fail)获得持久性存储。但是,如何获得www根的文件夹?每个文件插件文档我假设我不知何故需要使用cordova.file.applicationDirectory。不幸的是,文档没有指定在哪里/如何做到这一点。
有什么想法?
环境:
-Phonegap 3.4
- org.apache.cordova.file插件1.1.0( https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md )
- iOS模拟器7.1。
好的,现在计算出来。 .0
2)使用window.resolveLocalFileSystemURL
$ b示例:
window.resolveLocalFileSystemURL(cordova.file.applicationDirectory +'/ www / img',函数(dirEntry){...},errorHandler);
由于phonegap文件总是在www以下,所以请不要忘记该文件夹。
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.
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.
这篇关于Phonegap文件插件 - 将文件从应用程序包复制到持久性存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!