From 762ceefc7943ba63b5839d0dea64ca06d9dd3d01 Mon Sep 17 00:00:00 2001 From: Christopher Rose Date: Fri, 24 May 2019 11:43:48 +0530 Subject: [PATCH] Be careful or error logs Implement file downloads --- index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index c76a20a..29b52b5 100644 --- a/index.js +++ b/index.js @@ -41,6 +41,15 @@ let inDir = (dircheck,dirmain) => !path.relative(path.normalize(dircheck), dirma //Get folder details +app.post('/files/cat',(req,res,next)=>{ + const location = processing.mergedir(req.body.loc,settings) + //const nloc = path.normalize(req.body.loc); + const nloc = path.normalize(path.relative(settings.dirname,location)) + if(inDir(settings.dirname,location)){ + res.download(location,err=>{if(err) next(err)} ) + } +}) + app.post('/files/ls',(req,res,next)=>{ const location = processing.mergedir(req.body.loc,settings) @@ -97,7 +106,7 @@ app.listen(port,()=>{ }) app.use((err,req,res,next)=>{ - res.status(500).json({error:`${err}`}) + res.status(500).json({error:`Internal error.Try again.`}) }) module.exports = app; \ No newline at end of file