- Notifications
You must be signed in to change notification settings - Fork3
Promise-based HTML5 Filesystem API similar to Node.js fs module
NotificationsYou must be signed in to change notification settings
vitalets/bro-fs
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Promise-based wrapper overHTML5 Filesystem APIallowing to work with sandboxed filesystem in browser.
API is similar toNode.js fs module with some extra sugar.Currently it is supportedonly by Chrome.
- install from npm:
npm install bro-fs
- include directly from CDN via
<script>
tag:<scriptsrc="https://unpkg.com/bro-fs"></script>
- download manually the latest release
Withasync/await
:
constfs=require('bro-fs');(asyncfunction(){awaitfs.init({type:window.TEMPORARY,bytes:5*1024*1024});awaitfs.mkdir('dir');awaitfs.writeFile('dir/file.txt','hello world');constcontent=awaitfs.readFile('dir/file.txt');console.log(content);// => "hello world"})();
or with.then()
:
fs.init({type:window.TEMPORARY,bytes:5*1024*1024}).then(()=>fs.mkdir('dir')).then(()=>fs.writeFile('dir/file.txt','hello world')).then(()=>fs.readFile('dir/file.txt')).then(content=>console.log(content));// => "hello world"
See more usage examples intest directory.
Current:
- https://dev.w3.org/2009/dap/file-system/file-dir-sys.html (Chrome)
- https://wicg.github.io/entries-api (Firefox and Edge)
Coming (draft):
Discussion:
- filer.js - unix-like commands, callbacks
- html5-fs - looks obsolete, callbacks
- chromestore.js - looks obsolete, callbacks
- BrowserFS - many backends, callbacks
- fs-web - store files in IndexedDB, not html5 filesystem
- web-fs - abandoned
- browserify-fs - uses leveldb under hood, callbacks
- fs-browserify - abandoned
- dom-fs - abandoned
MIT @Vitaliy Potapov
About
Promise-based HTML5 Filesystem API similar to Node.js fs module
Topics
Resources
Stars
Watchers
Forks
Packages0
No packages published