mirror of
https://github.com/plankanban/planka.git
synced 2025-07-22 22:59:44 +02:00
parent
f20a3d50f5
commit
97f4c0ab0d
27 changed files with 2180 additions and 702 deletions
41
server/api/hooks/file-manager/index.js
Normal file
41
server/api/hooks/file-manager/index.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
const LocalFileManager = require('./LocalFileManager');
|
||||
const S3FileManager = require('./S3FileManager');
|
||||
|
||||
/**
|
||||
* file-manager hook
|
||||
*
|
||||
* @description :: A hook definition. Extends Sails by adding shadow routes, implicit actions,
|
||||
* and/or initialization logic.
|
||||
* @docs :: https://sailsjs.com/docs/concepts/extending-sails/hooks
|
||||
*/
|
||||
|
||||
module.exports = function defineFileManagerHook(sails) {
|
||||
let instance = null;
|
||||
|
||||
const createInstance = () => {
|
||||
instance = sails.hooks.s3.isActive()
|
||||
? new S3FileManager(sails.hooks.s3.getClient())
|
||||
: new LocalFileManager();
|
||||
};
|
||||
|
||||
return {
|
||||
/**
|
||||
* Runs when this Sails app loads/lifts.
|
||||
*/
|
||||
|
||||
async initialize() {
|
||||
sails.log.info('Initializing custom hook (`file-manager`)');
|
||||
|
||||
return new Promise((resolve) => {
|
||||
sails.after('hook:s3:loaded', () => {
|
||||
createInstance();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
getInstance() {
|
||||
return instance;
|
||||
},
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue