4.1.0 • Published 11 months ago
fs-chunk-store v4.1.0
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', // optional: path to file (default: temp file will be used)
length: 100 // optional: file length in bytes (default: file expands based on `put`s)
})
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/' // optional: if specified the file paths will be treated as relative, not absolute
})
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) // '0123456789' as a buffer
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.
4.1.0
11 months ago
4.0.1
1 year ago
4.0.0
1 year ago
3.0.1
2 years ago
2.0.5
2 years ago
3.0.0
2 years ago
2.0.4
3 years ago
2.0.3
3 years ago
2.0.2
4 years ago
2.0.1
5 years ago
2.0.0
5 years ago
1.7.0
6 years ago
1.6.5
7 years ago
1.6.4
8 years ago
1.6.3
8 years ago
1.6.2
8 years ago
1.6.1
8 years ago
1.6.0
8 years ago
1.5.0
8 years ago
1.4.0
8 years ago
1.3.5
8 years ago
1.3.4
9 years ago
1.3.3
9 years ago
1.3.2
9 years ago
1.3.1
9 years ago
1.3.0
9 years ago
1.2.0
9 years ago
1.1.0
9 years ago
1.0.0
9 years ago