Skip to content

ReclaimSoftware/rs-storage-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FS-backed KV storage with value streaming and partial reads

Build Status

constructor

{StorageWrapper} = require 'rs-storage-wrapper'

storage = new StorageWrapper {root_dir}

If root_dir does not exist or is not a directory, this will raise an error whose .notFound is true.

FS backing

The key foo/bar.png corresponds to the path #{root_dir}/foo/bar.png.

Keys must match /^[ !&'()\[\]a-zA-Z0-9_\/,.+-]+$/ and not contain "..".

get, put, exists, size

storage.get key, (e, value) ->
  return ... if e and e.notFound
  return ... if e
  ...

storage.put key, value, (e) ->

storage.exists key, (e, exists) ->

storage.size key, (e, num_bytes) ->
  return ... if e and e.notFound
  return ... if e
  ...

Streams, partial reads

storage.createWriteStream key, (e, stream) ->

stream = storage.createReadStream key

stream = storage.createReadStream key, {start, end}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published