Phonegap文件插件 - 将文件从应用程序包复制到持久性存储 [英] Phonegap file plugin- copy file from app package to persistent storage

查看:150
本文介绍了Phonegap文件插件 - 将文件从应用程序包复制到持久性存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆