mediastorage
v0.1.0
Published
Media storage wrapper
Downloads
9
Readme
Media storage wrapper
This is wrapper for media files uploading. For now it supports only two methods of storing files:
- Local (Just store files to local file system)
- Cloudinary (http://cloudinary.com/)
Installation
npm install mediastorage --save
Usage
Init
storage.init('local', {
destDir: path.join(__dirname, 'tmp'),
urlPrefix: '/images'
});
or
storage.init('cloudinary', {
cloud_name: 'cloudinary-name',
api_key: 'cloudinary-api-key',
api_secret: 'cloudinary-api-secret'
});
Upload image
storage.upload('/path/to/source/image.png', function (err, data) {
data.id; // Image id - can be used for image removing
});
Remove image
storage.remove('image.id', function (err) {
});