# fileprovider

> Abstracts file access

Latest version **1.3.5** (published 2017-10-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install fileprovider
pnpm add fileprovider
yarn add fileprovider
bun add fileprovider
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.5 |
| Published | 2017-10-31 |
| First published | 2017-10-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mike Carey |
| Maintainers | careym |

## Links

- npm: https://www.npmjs.com/package/fileprovider
- Repository: https://github.com/mike-carey/fileprovider
- Homepage: https://github.com/mike-carey/fileprovider#readme
- Issues: https://github.com/mike-carey/fileprovider/issues
- npm.io page: https://npm.io/package/fileprovider

## Dependencies (2)

- [fs-extra](https://npm.io/package/fs-extra.md) ^4.0.2
- [underscore](https://npm.io/package/underscore.md) ^1.8.3

## Recent versions

- 1.3.5 (latest) — 2017-10-31
- 1.3.2 — 2017-10-31
- 1.3.0 — 2017-10-31
- 1.2.2 — 2017-10-31
- 1.2.1 — 2017-10-30
- 1.2.0 — 2017-10-30
- 1.1.1 — 2017-10-27
- 1.1.0 — 2017-10-27

## README

# File Provider

[![Build Status](https://travis-ci.org/mike-carey/fileprovider.svg?branch=master)](https://travis-ci.org/mike-carey/fileprovider)
[![Coverage Status](https://coveralls.io/repos/github/mike-carey/fileprovider/badge.svg?branch=master)](https://coveralls.io/github/mike-carey/fileprovider?branch=master)
[![Test Coverage](https://api.codeclimate.com/v1/badges/8b2b532cfb311d232d7b/test_coverage)](https://codeclimate.com/github/mike-carey/fileprovider/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/8b2b532cfb311d232d7b/maintainability)](https://codeclimate.com/github/mike-carey/fileprovider/maintainability)

Abstracts the file storage into a single module


## Installation
Using NPM
```
npm install fileprovider
```

Using Yarn
```
yarn add fileprovider
```

## Usage
```javascript
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
2. Shift options if not provided

---
_Source: https://npm.io/package/fileprovider · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
