Process file type and send it over

This commit is contained in:
2019-05-21 20:31:41 +05:30
parent 4f01ee8cb8
commit 51775c76f2
5 changed files with 47 additions and 11 deletions

View File

@@ -18,12 +18,13 @@ app.use(bodyParser.json())
//Get the status of the folder and things related
app.get('/files',(req,res,next)=>{
fs.readdir(DIR,(err,stream)=>{
fs.readdir(DIR,{withFileTypes:true},(err,stream)=>{
if(err){
next(err)
}
else{
res.json({"filename":`${DIR}`,"rootdir":processing.dirprocess(stream,settings)});
//res.json(stream[0].isDirectory())
res.json({"filename":`${DIR}`,"loc":processing.dirprocess(stream,settings)});
}
})
})
@@ -39,14 +40,14 @@ app.put('/files/upload',(req,res)=>{
//Get folder details
app.post('/files/ls',(req,res,next)=>{
const location = processing.mergedir(req.body.loc,settings)
fs.readdir(location,(err,files)=>{
fs.readdir(location,{withFileTypes:true},(err,files)=>{
if(err){
next(err)
}
else{
res.json({
"location": location ,
"contents":files
"contents":processing.dirprocess(files,settings)
})
}
})