qostorage
Version:
File system based object storage, can also be used as a persistent KV database.
28 lines (22 loc) • 845 B
JavaScript
const qostorage = require("../storage.js")
const fs = require("fs")
const storage = new qostorage({
pathname: "../storage", // Storage directory.
chunkSize: 10737418240, // File fragment size.
blockSize: 1048576 // Block size.
})
process.on("beforeExit", async function () {
void await storage.drop()
process.exit(0)
})
storage.on("ready", async function () {
void await storage.push("test", fs.createReadStream("./a.jpg"))
void await storage.pull("test", fs.createWriteStream("./test.jpg"))
void await storage.insert("hello", "word")
let data = await storage.get("hello")
data && console.log(data.toString("utf8"))
console.log(await storage.remove("hello"))
console.log(await storage.remove("test"))
let hello = await storage.get("hello")
console.log(hello)
})