https://github.com/john-doherty/cordova-file-storage
An easy way to read/write files in Cordova
https://github.com/john-doherty/cordova-file-storage
cordova javascript
Last synced: about 1 year ago
JSON representation
An easy way to read/write files in Cordova
- Host: GitHub
- URL: https://github.com/john-doherty/cordova-file-storage
- Owner: john-doherty
- License: mit
- Created: 2021-01-08T16:38:53.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-09-20T08:28:22.000Z (over 2 years ago)
- Last Synced: 2025-04-21T12:58:10.011Z (about 1 year ago)
- Topics: cordova, javascript
- Homepage:
- Size: 11.7 KB
- Stars: 12
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cordova-file-storage
An easy way to read/write files in Cordova.
## Install
Add the [cordova-file-storage.js](./cordova-file-storage.js) to your project.
## Usage
```js
// the object you want to save
var objectToSave = { firstName: 'John', lastName: 'Doherty' };
// the filename and extension you want to use
var filename = 'whatever.txt';
// the data to write (convert JSON object to a string)
var data = JSON.stringify(objectToSave);
// call write with params, .then executes with the filePath once complete
fileStorage.write(filename, data).then(function(filePath) {
console.log(filePath);
})
.catch(function(err) {
// this executes if something went wrong
console.warn(err);
});
```
This will use external (unprotected storage) by default, set `useSandbox: true` to save files in a protected location where users and external app are unable to access them.
## Star the repo
If you find this useful, please star the repo. It helps me priorities which open source bug fixes.
## History
For change-log, check [releases](https://github.com/john-doherty//cordova-file-storage/releases).
## License
Licensed under [MIT License](LICENSE) © [John Doherty](https://twitter.com/mrjohndoherty)