SimpleFS

A minimal, extensible and promise based filesystem layer for modern browsers.
Live Demo
Supported storage backend
Simple-fs provides two storage backend. It's possible to write your own stoage backend using Storage API
import { IndexedDbStorage } from '@forlagshuset/simple-fs'
- Memory (experimental and used for testing)
import { MemoryStorage } from '@forlagshuset/simple-fs'
Installation
npm:
npm install --save @forlagshuset/simple-fs
Usage
browser (umd):
<script src='https://unpkg.com/@forlagshuset/simple-fs@latest/dist/SimpleFS.js' async></script>
<script>
const fs = new SimpleFS.FileSystem()
await fs.mkdir('/myproject')
const content = new Blob(['This is my cool project'], {type: 'plain/text'})
await fs.writeFile('/myproject/test.txt', content)
let blob = await fs.readFile('/myproject/test.txt')
</script>
browser (modules)
import SimpleFS from '@forlagshuset/simple-fs'
import SimpleFS from "//unpkg.com/@forlagshuset/simple-fs?module"
const fs = new SimpleFS.FileSystem()
await fs.mkdir('/myproject')
const content = new Blob(['This is my cool project'], {type: 'plain/text'})
await fs.writeFile('/myproject/test.txt', content)
let blob = await fs.readFile('/myproject/test.txt')
API
FileSystem
constructor({storage: storageObj = new IndexedDbStorage('my-storage-name')})
mkdir(path: string)
mkdirParents(path: string)
rmdir(path: string)
rmdirRecursive(path: string)
readFile(path: string, options={})
writeFile(path: string, data: Blob, options={})
outputFile(path: string, data: Blob, options={})
bulkOutputFiles([{path: string, blob: Blob, options:{}])
unlink(path: string)
exists(path: string)
stats(path: string)
Browser support
- Chrome
- IE Edge
- Firefox
- Safari