# ss-node-filestorage

> Filestorage for Node.

Latest version **0.1.1** (published 2018-11-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install ss-node-filestorage
pnpm add ss-node-filestorage
yarn add ss-node-filestorage
bun add ss-node-filestorage
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2018-11-19 |
| First published | 2018-06-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 20.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Stanislav Sahnyuk |
| Maintainers | vt-bogachev |
| Keywords | node, files, storage, filestorage, express |

## Links

- npm: https://www.npmjs.com/package/ss-node-filestorage
- Repository: https://github.com/vt-bogachev/ss-node-filestorage
- Homepage: https://github.com/vt-bogachev/ss-node-filestorage#readme.md
- Issues: https://github.com/vt-bogachev/ss-node-filestorage/issues
- npm.io page: https://npm.io/package/ss-node-filestorage

## Dependencies (1)

- [file-type](https://npm.io/package/file-type.md) ^8.1.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 0.1.1 (latest) — 2018-11-19
- 0.1.0 — 2018-08-08
- 0.0.4 — 2018-07-18
- 0.0.2 — 2018-06-01
- 0.0.1 — 2018-06-01

## README

![badge](https://travis-ci.org/vt-bogachev/ss-node-filestorage.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/vt-bogachev/ss-node-filestorage/badge.svg)](https://coveralls.io/github/vt-bogachev/ss-node-filestorage)

FileStorage
=========================

Simple module for saving and loading files into local storage.

If you want to see new features, create new issue, please.

[https://github.com/vt-bogachev/ss-node-filestorage/issues](https://github.com/vt-bogachev/ss-node-filestorage/issues)

Installation
------------
```
npm i ss-node-filestorage
```

How to using?
```javascript
const FileStorage = require('ss-node-filestorage')

// Init storage
FileStorage.init('avatar', new FileStorage.LocalStorage({
  path: `${__dirname}/_storage/public`
}),{
  url:'http://localhost:8000'
})

// Save file
// File will be save as __dirname/_storage/public/filename.text
FileStorage.use('avatar').
  put('filename.text','content file')

// Get file
FileStorage.use('avatar').
  get('filename.text','content file').
  then((content)=>console.log(content))
  
// Get file url
FileStorage.use('avatar').
  getUrl('filename.text').
  then((fileUrl)=>console.log(fileUrl))
  
// Get path to file  
FileStorage.use('avatar').
  getPath('filename.text').
  then((fileUrl)=>console.log(fileUrl))  
  
// Remove file  
FileStorage.use('avatar').
  remove('filename.text').
  then((result)=>console.log(result))
 

// ================================================
// OR
// ================================================

const avatarStorage = FileStorage.use('avatar');
Promise.all([
  avatarStorage.get('file1'),  
  avatarStorage.get('file2')
]).then(([file1Content, file2Content])=>{
  console.log({file1Content, file2Content})
})

// ================================================
// Validation (@beta)
// Available 2 types of validation:
//  size - validation by size of content
//    size: {min: 10, max: 100}
//    size: {min: 10}
//    size: {max: 100}
//  types - validation by tipe of file
//    types: ['png']
//    types: ['png','jpg']
// ================================================
FileStorage.init('image', new FileStorage.LocalStorage({
  path: `${__dirname}/_storage/image`
}), {
  url: 'http://localhost:8000',
  validators: {
    size: {min: 10, max: 100},
    types: ['png']
  }
})

```

Tools
---------------------------
[TravisCI](https://travis-ci.org/), [Coveralls](https://coveralls.io)

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