opfs_blob_store
v0.0.3
Published
Store blobs in OPFS
Readme
store sha256 addressable data in OPFS
import OpfsBlobStore from "opfs_blob_store"
// API
const bs = await OpfsBlobStore.create()
// download, check, and store
await bs.fetch(hash, url, onProgress)
// verify data
await bs.verify(hash, onProgress)
// does file exists
await bs.has(hash)
// retrive file from store
await bs.get(hash)
// delete file from store
await bs.delete(hash)
// list all data
await bs.keys()
// how to use
const hash = "de24a48f120dd2c7257cbdccf59b5421a24e9c1bc7bd6920df5f026534314b03"
const url = "https://upload.wikimedia.org/wikipedia/commons/1/10/Ursus_americanus_tree.jpg"
const bs = await OpfsBlobStore.create()
const onProgress = ratio => `${Math.round(ratio * 100, 2)}%`
await bs.fetch(hash, url, onProgress)
await bs.verify(hash, onProgress)
const file = await bs.get(hash)