parent
f64074f34a
commit
eee01ce3d3
3 changed files with 59 additions and 0 deletions
@ -0,0 +1,28 @@ |
||||
const path = require('path'); |
||||
|
||||
const SERVER_PATHS = { |
||||
mnt: { |
||||
shared: { |
||||
incoming: {}, |
||||
}, |
||||
}, |
||||
}; |
||||
|
||||
const generatePaths = ( |
||||
currentObject, |
||||
parents = path.parse(process.cwd()).root, |
||||
) => { |
||||
Object.keys(currentObject).forEach((pathKey) => { |
||||
const currentPath = path.join(parents, pathKey); |
||||
|
||||
currentObject[pathKey].self = currentPath; |
||||
|
||||
if (pathKey !== 'self') { |
||||
generatePaths(currentObject[pathKey], currentPath); |
||||
} |
||||
}); |
||||
}; |
||||
|
||||
generatePaths(SERVER_PATHS); |
||||
|
||||
module.exports = SERVER_PATHS; |
@ -0,0 +1,16 @@ |
||||
const multer = require('multer'); |
||||
|
||||
const SERVER_PATHS = require('../lib/consts/SERVER_PATHS'); |
||||
|
||||
const storage = multer.diskStorage({ |
||||
destination: (request, file, callback) => { |
||||
callback(null, SERVER_PATHS.mnt.shared.incoming.self); |
||||
}, |
||||
filename: (request, file, callback) => { |
||||
callback(null, file.originalname); |
||||
}, |
||||
}); |
||||
|
||||
const uploadSharedFiles = multer({ storage }); |
||||
|
||||
module.exports = uploadSharedFiles; |
Loading…
Reference in new issue