Be careful or error logs
Implement file downloads
This commit is contained in:
11
index.js
11
index.js
@@ -41,6 +41,15 @@ let inDir = (dircheck,dirmain) => !path.relative(path.normalize(dircheck), dirma
|
|||||||
|
|
||||||
|
|
||||||
//Get folder details
|
//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)=>{
|
app.post('/files/ls',(req,res,next)=>{
|
||||||
const location = processing.mergedir(req.body.loc,settings)
|
const location = processing.mergedir(req.body.loc,settings)
|
||||||
@@ -97,7 +106,7 @@ app.listen(port,()=>{
|
|||||||
})
|
})
|
||||||
|
|
||||||
app.use((err,req,res,next)=>{
|
app.use((err,req,res,next)=>{
|
||||||
res.status(500).json({error:`${err}`})
|
res.status(500).json({error:`Internal error.Try again.`})
|
||||||
})
|
})
|
||||||
|
|
||||||
module.exports = app;
|
module.exports = app;
|
Reference in New Issue
Block a user