koop-localfs

1.1.2 • Public • Published

Koop Local FS

Greenkeeper badge A filesystem plugin for koop that supports setting a root directory for all actions

npm travis

Project goal

In order to allow different koop modules to write to local disk without specifying a machine specific absolute path, this module resolves all relative paths to the same base directory. So you can callkoop.fs.createReadStream('foo.txt') and always know that you can open foo without changing the working directory.

Usage

In default.json

{
  "filesystem": {
    "local": {
      "rootDir": "/var/koop/files"
    }
  }
}

In server.js

const config = require('config')
const koop = require('koop')(config)
const LocalFs = require('koop-localfs')
 
koop.register(LocalFs)

Supported functions

  • stat - Get information about a file
  • createReadStream: create a readable stream from a file on disk
  • createWriteStream: create a writeable stream you can pipe to
  • writeFile: write a file to disk
  • readFile: read a file from disk
  • unlink: delete a file
  • mkdir: make a directory
  • rmdir: remove an empty directory
  • rmdirp: recursively remove a directory and its contents
  • realpathSync: resolve the absolute path when given a relative path

/koop-localfs/

    Package Sidebar

    Install

    npm i koop-localfs

    Weekly Downloads

    67

    Version

    1.1.2

    License

    Apache-2.0

    Unpacked Size

    7.37 kB

    Total Files

    7

    Last publish

    Collaborators

    • dmfenton
    • rgwozdz