Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bagit-fs

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bagit-fs

node fs implementation for bagit format

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

bagit-fs

node fs implementation for the bagit spec.

npm travis standard

Install

npm install bagit-fs

Usage

var BagIt = require('bagit-fs')

var bag = BagIt('/put/my/bag/here', 'sha256', {'Contact-Name': 'Joe Hand'})

// write files to bag's data folder
fs.createReadStream('readme.md').pipe(bag.createWriteStream('/readme.md'))

// ... LATER after all files are written
bag.finalize(function () {
  console.log('finalized')
})

See example/index.js for an example usage with mirror-folder.

API

var bag = BagIt(dest, algorithm, [bagInfo])

  • dest is the destination directory for the bag
  • algorithm is a string specifying which checksum algorithms to use. Default is sha256.
  • bagInfo is a object with data to be written to bag-info.txt, e.g. bagInfo = {'Contact-Name': 'Joe Hand'}. See below for details on bag-info.txt.

bag.finalize(cb)

Finalize the bag, writing bag-info.txt and bagit.txt. Date and size are automatically written to the info. This should only be called when the bag is complete.

fs API

Several of the node fs functions are implemented allowing you to create or read from bags like the fs. Most of these just wrap the fs calls to act on the bag's data folder.

  • bag.createWriteStream(name, opts, cb) - writes file to bagDir/data and the checksum hash to the manifest.
  • bag.mkdir(name, opts, cb) - make a dir in the data/ folder.
  • bag.createReadStream(name, opts, cb)
  • bag.mkdir(name, cb)
  • bag.stat(name, cb)
  • bag.lstat(name, cb)
  • bag.readdir(name, cb)
  • bag.unlink(name, cb)
  • bag.rmdir(name, cb)

BagIt Spec Support

bagit-fs is a fully compliant implementation of the specification but there are some optional parts not yet implemented.

TODO:

Bag Info

bag-info spec

The "bag-info.txt" file is a tag file that contains metadata elements describing the bag and the payload. The metadata elements contained in the "bag-info.txt" file are intended primarily for human readability. All metadata elements are optional and MAY be repeated.

Bagging-Date and Bag-Size are written automatically on bag.finalize().

Here is an example "bag-info.txt" file:

Source-Organization: Spengler University
Organization-Address: 1400 Elm St., Cupertino, California, 95014
Contact-Name: Edna Janssen
Contact-Phone: +1 408-555-1212
Contact-Email: ej@spengler.edu
External-Description: Uncompressed greyscale TIFF images from the
    Yoshimuri papers colle...
Bagging-Date: 2008-01-15
External-Identifier: spengler_yoshimuri_001
Bag-Size: 260 GB
Payload-Oxum: 279164409832.1198
Bag-Group-Identifier: spengler_yoshimuri
Bag-Count: 1 of 15
Internal-Sender-Identifier: /storage/images/yoshimuri
Internal-Sender-Description: Uncompressed greyscale TIFFs created
    from microfilm and are...

License

MIT

FAQs

Package last updated on 09 Apr 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc