level-blobs
Save binary blobs in level and stream then back.
Similar to level-store but streams2 and with support for random access writes and reads
npm install level-blobs
Usage
var blobs = require('level-blobs');
var level = require('level');
var db = level('/tmp/my-blobs-db');
var bl = blobs(db);
var ws = blobs.createWriteStream('my-file.txt');
ws.on('finish', function() {
var rs = blobs.createReadStream('my-file.txt');
rs.pipe(process.stdout);
});
ws.write('hello ');
ws.write('world');
ws.end();
API
blobs(db, opts)
Create a new blobs instance. Options default to
{
blockSize: 65536,
batch: 100
}
bl.createReadStream(name, opts)
Create a read stream for name
. Options default to
{
start: 0
end: Infinity
}
bl.createWriteStream(name, opts)
Create a write stream to name
. Options default to
{
start: 0
append: false
}
bl.read(name, opts, cb)
Create a read stream and buffer the stream into a single buffer that is passed to the callback.
Options are passed to createReadStream
.
bl.write(name, data, opts, cb)
Write data
to name
and call the callback when done.
Options are passed to createWriteStream
.
bl.remove(name, cb)
Remove name
from the blob store
License
MIT