uh-storage

3.0.0 • Public • Published

UH-Storage

Unified handler for storage System

Easy to use, separate storage handler between node environment

Now you can easy to separate storage handler between development, staging or production environment.

var gm = require('gm').subClass({ imageMagick: true });
var storage = require('./../../../uh-storage')(CONFIG['uh-storage']);
 
gm(req.file.path)
  .resize(125, 125)
  .compress('JPEG')
  .stream()
  .pipe(storage.stream(req.file, {}, function (err, result) {
      console.log(err, result);
   }))

Local configuration

You can easily set parameter in global CONFIG variable

GLOBAL.CONFIG = {
  'uh-storage': {
    provider: {
      use: 'local',
      params: {
        path: path.normalize(UPLOAD_PATH),
        url: URL_TO_UPLOAD_PATH
      }
    }
  }  
}

AWS S3 configuration

You can easily set parameter in global CONFIG variable

GLOBAL.CONFIG = {
  'uh-storage': {
    provider: {
      use: 's3',
      params: {
        accessKeyId: AWS_ACCESS_KEY_ID,
        accessKeySecret: AWS_ACCESS_KEY_SECRET,
        region: AWS_REGION,
        bucket: AWS_S3_BUCKET
      }
    }
  }
}

/uh-storage/

    Package Sidebar

    Install

    npm i uh-storage

    Weekly Downloads

    1

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    7.23 kB

    Total Files

    6

    Last publish

    Collaborators

    • hengkiardo
    • uh-engineer