You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

caslet

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

caslet

A simple content addressable system

0.1.1
latest
Source
npmnpm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

CASlet - a Simple Content Addressable Storage System

caslet is a simple content storage system that allows you to store files uniquely (i.e. the same file will be stored only once).

Install

npm install -g caslet

Usage

Command Line Usage

# to store files into the storage system.
$ caslet store /file/to/be/stored destination/file/path
==> a sha1 hash will be returned.

# get the file by destination/file/path
$ caslet get destination/file/path target/file/path

# get the file by hash
$ caslet gethash hash target/file/path

By default, caslet will hold its content at $HOME/.caslet directory. To change the particular directory, pass in -b|--baseDir a/different/directory as part of the command line call.

$ caslet -b ./assets store /file/to/be/stored destination/file/path
$ caslet -b ./assets pathget destination/flie/path target/file/path
$ caslet -b ./assets hashget hash target/file/path

API

var CAS = require('caslet');
CAS.initialize({baseDir: './assets'}, function(err, cas) {
  cas.store(...);
  cas.storeWithPath(...);
  cas.get(...);
});

CAS.initialize(options, function(err, cas) { ... })

Create the CAS object with CAS initialize - this is where we pass in the initialization parameters.

Option

The following are the values of the option object

  • baseDir: the root directory of the CAS repo. Defaults to $HOME/.caslet if not passed in.

The returned cas object have the following functions:

cas.store(filePath, function(err, hash) { ... })

This call stores the file located at filePath to destPath, and returns its sha1 hash through the callback.

cas.storeWithPath(filePath, destPath, function(err, hash) { ... })

This wraps around cas.store with an addition of destPath that can be also be used for retrieving the file.

cas.get(options, function (err, stream) { ... })

Get the content as a stream.

Options is a JSON object with either hash (the hash returned) or path (the path supplied to cas.storeWithPath).

Keywords

content addressable storage

FAQs

Package last updated on 04 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts