1 line
53 KiB
JSON
1 line
53 KiB
JSON
|
{"name":"Filer","tagline":"Node-like file system for browsers","body":"[![NPM](https://nodei.co/npm/filer.png?downloads=true&stars=true)](https://nodei.co/npm/filer/)\r\n\r\n[![Build Status](https://secure.travis-ci.org/filerjs/filer.png?branch=develop)](http://travis-ci.org/filerjs/filer)\r\n\r\n###Filer\r\n\r\nFiler is a POSIX-like file system interface for node.js and browser-based JavaScript.\r\n\r\n###Compatibility\r\n\r\nFiler is known to work in the following browsers/versions, with the specified [Storage Providers](#providers):\r\n\r\n* node.js: v0.10.*+\r\n* IE: 10+ (IndexedDB)\r\n* Firefox: 26+ (IndexedDB)\r\n* Chrome: 31+ (IndexedDB, WebSQL)\r\n* Safari: 7.0+ (WebSQL)\r\n* Opera: 19+ (IndexedDB, WebSQL)\r\n* iOS: 3.2+ (WebSQL)\r\n* Android Browser: 2.1-4.4 (WebSQL), 4.4+ (IndexedDB)\r\n\r\nNOTE: if you're interested in maximum compatibility, use the `Fallback` provider instead of `Default`.\r\nSee the section on [Storage Providers](#providers).\r\n\r\n### Contributing\r\n\r\nWant to join the fun? We'd love to have you! See [CONTRIBUTING](https://github.com/filerjs/filer/blob/develop/CONTRIBUTING.md).\r\n\r\n### How to Get It\r\n\r\nFiler can be obtained in a number of ways:\r\n\r\n1. npm - `npm install filer`\r\n2. bower - `bower install filer`\r\n3. download pre-built versions: [filer.js](https://raw.github.com/filerjs/filer/develop/dist/filer.js), [filer.min.js](https://raw.github.com/filerjs/filer/develop/dist/filer.min.js)\r\n\r\n### Loading and Usage\r\n\r\nFiler is built as a UMD module and can therefore be loaded as a CommonJS or AMD module, or used via the global.\r\n\r\n```javascript\r\n// Option 1: Filer loaded via require() in node/browserify\r\nvar Filer = require('filer');\r\n\r\n// Option 2: Filer loaded via RequireJS\r\nrequirejs.config({\r\n baseUrl: '/',\r\n paths: {\r\n 'filer': 'filer/dist/filer'\r\n }\r\n});\r\nrequirejs(['filer'], function(Filer) {...}\r\n\r\n// Option 3: Filer on global\r\nvar Filer = window.Filer;\r\n```\r\n\r\n### Getting Started\r\n\r\nFiler is as close to the node.js [fs module](http://nodejs.org/api/fs.html) as possible,\r\nwith the following differences:\r\n\r\n* No synchronous versions of methods (e.g., `mkdir()` but not `mkdirSync()`).\r\n* No permissions (e.g., no `chown()`, `chmod()`, etc.).\r\n* No support for stream-based operations (e.g., `fs.ReadStream`, `fs.WriteStream`).\r\n\r\nFiler has other features lacking in node.js (e.g., swappable backend\r\nstorage providers, extended attributes, etc).\r\n\r\nLike node.js, the API is asynchronous and most methods expect the caller to provide\r\na callback function (note: like node.js, Filer will supply one if it's missing).\r\nErrors are passed to callbacks through the first parameter. As with node.js,\r\nthere is no guarantee that file system operations will be executed in the order\r\nthey are invoked. Ensure proper ordering by chaining operations in callbacks.\r\n\r\n### Overview\r\n\r\nTo create a new file system or open an existing one, create a new `FileSystem`\r\ninstance. By default, a new [IndexedDB](https://developer.mozilla.org/en/docs/IndexedDB)\r\ndatabase is created for each file system. The file system can also use other\r\nbackend storage providers, for example [WebSQL](http://en.wikipedia.org/wiki/Web_SQL_Database)\r\nor even RAM (i.e., for temporary storage). See the section on [Storage Providers](#providers).\r\n\r\n```javascript\r\nvar fs = new Filer.FileSystem();\r\nfs.open('/myfile', 'w+', function(err, fd) {\r\n if (err) throw err;\r\n fs.close(fd, function(err) {\r\n if (err) throw err;\r\n fs.stat('/myfile', function(err, stats) {\r\n if (err) throw err;\r\n console.log('stats: ' + JSON.stringify(stats));\r\n });\r\n });\r\n});\r\n```\r\n\r\nFor a complete list of `FileSystem` methods and examples, see the [FileSystem Instance Methods](#FileSystemMethods)\r\nsection below.\r\n\r\nFiler also supports node's Path module. See the [Filer.Path](#FilerPath) section below.\r\n\r\nIn addition, common shell operations (e.g., rm, touch, cat, etc.) are supported via the\
|