如何在Meteor-Cordova中读取/写入文件? [英] How to read/write a file in Meteor-Cordova?

查看:63
本文介绍了如何在Meteor-Cordova中读取/写入文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过几天无用的研究(我已经尝试了Internet,Github,SO等上的所有可能的教程和代码片段),我急切地寻找一种使用Cordova文件插件的方法:




  • 读取文本/ json文件

  • 写文本文件



在大多数情况下,我会得到fileErrror错误代码1和5。
另外,我不确定是否应该创建目录资产,公共目录还是其他目录。 p>

我正在使用Crosswalk软件包。
我已经尝试过的代码示例: https://stackoverflow.com/questions/33156697/filesystem-api-cordova-file-is-created-but-cant-be编写

解决方案

而不是 window.requestFileSystem(),请尝试使用 window.resolveLocalFileSystemURL()



此处的完整说明: FileError {code:5}尝试在Meteor 1.4 Cordova中使用绝对文件路径



此处的示例代码: https://github.com/meonkeys/ cordova-file-test / tree / solution


After days of useless research (I've tried all possible tutorials and code snippets on the Internet, Github, SO etc.) I'm desperately looking for a way to use Cordova file plugin to:

  • read a text / json file
  • write a text file

In most of my attemps I get fileErrror error codes 1 and 5. Also, I'm not sure whether I should create a directory assets, or public or whatever.

I'm using Crosswalk package. An example of code I've tried out: https://stackoverflow.com/questions/33156697/filesystem-api-cordova-file-is-created-but-cant-be-written

解决方案

Instead of window.requestFileSystem(), try using window.resolveLocalFileSystemURL(). That worked for me.

Full explanation here: FileError {code: 5} trying to use absolute file paths with Meteor 1.4 Cordova

Example code here: https://github.com/meonkeys/cordova-file-test/tree/solution

这篇关于如何在Meteor-Cordova中读取/写入文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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