How to read/write a file in Meteor-Cordova?

徘徊边缘 提交于 2020-01-05 10:10:09

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/33189234/how-to-read-write-a-file-in-meteor-cordova

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