1.3.5 • Published 7 years ago

fileprovider v1.3.5

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

File Provider

Build Status Coverage Status Test Coverage Maintainability

Abstracts the file storage into a single module

Installation

Using NPM

npm install fileprovider

Using Yarn

yarn add fileprovider

Usage

const Storage = require('fileprovider').initialize('Local', {dir: '/tmp'})

Storage.read('/tmp/foo.txt', (err, data) => {
    if (err) {
        throw err
    }

    console.log(data)
})


// If the STORAGE_PROVIDER variable is set
process.env.STORAGE_PROVIDER = 'Local'
const Storage = require('fileprovider')

Storage.read('/tmp/foo.txt', (err, data) => {
    if (err) {
        throw err
    }

    console.log(data)
})

// If the STORAGE_PROVIDER variable is set
process.env.STORAGE_PROVIDER = 'Local'
process.env.STORAGE_OPTIONS = '{"root": "/tmp"}'
const Storage = require('fileprovider')

Storage.read('foo.txt', (err, data) => {
    if (err) {
        throw err
    }

    console.log(data)
})

Configuration

The STORAGE_PROVIDER environment variable can be set to define the provider automatically without calling the initialize function. The STORAGE_OPTIONS environment variables can be set to define the provider options automatically without calling the initialize function. Only works if the STORAGE_PROVIDER environment variable has also been set.

TODO

  1. Shift options if not provided
1.3.5

7 years ago

1.3.2

7 years ago

1.3.0

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago