fs-chunk-store

Filesystem (fs) chunk store that is abstract-chunk-store compliant

Install
npm install fs-chunk-store
Usage
Back the store with a single file
var FSChunkStore = require('fs-chunk-store')
var chunks = new FSChunkStore(10, {
path: '/tmp/my_file',
length: 100
})
Back the store with multiple files
var FSChunkStore = require('fs-chunk-store')
var chunks = new FSChunkStore(10, {
files: [
{ path: 'folder/file1.txt', length: 12 },
{ path: 'folder/file2.txt', length: 8 },
{ path: 'folder/file3.txt', length: 30 }
],
path: 'C:/user/'
})
Specifying a path to the store will create a folder in that path, and on destroy, will delete the folder along with all it's contents
put, get, close, destroy
chunks.put(0, Buffer.from('0123456789'), function (err) {
if (err) throw err
chunks.get(0, function (err, chunk) {
if (err) throw err
console.log(chunk)
chunks.close(function (err) {
if (err) throw err
console.log('/tmp/my_file file descriptor is closed')
chunks.destroy(function (err) {
if (err) throw err
console.log('/tmp/my_file file is deleted')
})
})
})
})
License
MIT. Copyright (c) Feross Aboukhadijeh.