node package manager
Love JavaScript? Your insights can make it even better. Take the 2017 JavaScript Ecosystem Survey »

engined-storage

engined-storage

Storage service for engined, used to managing various storage backend.

NPM

Installation

Install via NPM:

npm install engined-storage

Usage

Start engined-storage service in engined, see example below:

const { Manager } = require('engined');
const StorageService = require('engined-storage');
 
const storage = StorageService();
 
const main = async () => {
 
    // Create manager
    let serviceManager = new Manager({ verbose: true });
 
    // Adding service to manager
    serviceManager.add('Storage', storage);
 
    // Start all services
    await serviceManager.startAll();
};
 
main();

Using specific storage backend

Here is example to get agent for specific backend to save file:

 
// Using local storage backend
let localAgent = this.getContext('Storage').getAgent('local');
 
// Save file
localAgent.save(readStream, 'myimage.png', 12345);

Register storage backend

 
// Register storage backend
this.getContext('Storage').registerAgent('local', agent);

License

Licensed under the MIT License

Authors

Copyright(c) 2017 Fred Chien(錢逢祥) <cfsghost@gmail.com>