# storage-lib

> high level s3 helper

Latest version **0.1.3** (published 2016-12-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install storage-lib
pnpm add storage-lib
yarn add storage-lib
bun add storage-lib
```

## 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.3 |
| Published | 2016-12-01 |
| First published | 2016-08-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+4 in 3 direct dependencies) |
| Install scripts | no |
| Author | axnux |
| Maintainers | axnux |
| Keywords | s3, storage, library |

## Links

- npm: https://www.npmjs.com/package/storage-lib
- npm.io page: https://npm.io/package/storage-lib

## Dependencies (4)

- [mime](https://npm.io/package/mime.md) ^1.3.4
- [lodash](https://npm.io/package/lodash.md) ~4.17.2
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.7.9
- [request](https://npm.io/package/request.md) ^2.74.0

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2016-12-01
- 0.1.2 — 2016-08-30
- 0.1.1 — 2016-08-30
- 0.1.0 — 2016-08-30

## README

# S3 storage helper  [![wercker status](https://app.wercker.com/status/a891080ef23f64251eb729d499efbb46/s/master "wercker status")](https://app.wercker.com/project/byKey/a891080ef23f64251eb729d499efbb46)   [![Dependency Status](https://gemnasium.com/badges/github.com/axnux/storage-lib.svg)](https://gemnasium.com/github.com/axnux/storage-lib)   [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/axnux/storage-lib/issues)   [![npm version](https://badge.fury.io/js/storage-lib.svg)](https://badge.fury.io/js/storage-lib)
A high level nodejs s3 wrapper



## Installation
```shell
npm install storage-lib
```


## Config
```js
var config = {   // must provide these
  s3Options: {
    accessKeyId: '',
    secretAccessKey: '',
    region: ''
  },
  uploads: {
    s3Bucket: '',
    dest: '' // default: '/tmp/upload'
  }
}
```


## Usage
```js
var storageHelper = require('storage-lib')(config) // see the above config

// check remote file exists
storageHelper.remoteFileExists('http://remote.file.url', function (err, exists) {
  // exists: true, false
})

// get the local storage folder path
storageHelper.storageFolder() // same as config.uploads.dest

// download the remote file with and rename as local/file/path.txt (inside the folder  storageHelper.storageFolder())
storageHelper.downloadFile('http://remote.file.url', 'local/file/path.txt', function (err, fullLocalPath) {
  // 'fullLocalPath' will be:
  // config.uploads.dest + '/' + 'local/file/path.txt'
})

// delete file from s3
storageHelper.removeFile('remote/file/path/in/s3', function () {
  //
})

// upload file to s3
storageHelper.toS3('/full/local/file/path.txt', 'remote/file/path/in/s3.txt', function (err, url) {
  // will upload the file from '/full/local/file/path.txt' to s3
  // 'url' will be:
  // a valid http(s)://url.pointing.tos3bucket/remote/file/path/in/s3.txt
})

```



## License
(The MIT License)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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