uh-storage
v3.0.0
Published
Unified handler for storage system
Downloads
9
Readme
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
}
}
}
}