799967501@qq.com

添加接口:判断视频文件是否存在

... ... @@ -249,5 +249,42 @@ router.post('/recording', async function (req, res, next) {
})
// 判断该视频文件是否存在
router.post('/fileExists', async function (req, res, next) {
let fileConfig = new MediaCreat().getConfigFileJson()
const { PROJECTCATALOG } = JSON.parse(fileConfig)
const body = req.body
if(!body.siteId) {
res.send({ code: 2,message:"机构编码无效" });
return
}
if(!body.classId) {
res.send({ code: 3,message:"课堂号无效" });
return
}
let timeDir = PROJECTCATALOG + "/media/" + body.siteId
if (!fs.existsSync(timeDir)) {
res.send({ code: 4,message:"目录未生成" });
return
}
const timeFiles = fs.readdirSync(timeDir)
let classIdStr = `${body.classId}.mp4`
let isFile = false
for(let i=0;i<timeFiles.length;i++){
let classDir = `${timeDir}/${timeFiles[i]}`
const classFiles = fs.readdirSync(classDir)
if(classFiles.indexOf(classIdStr) > -1){
isFile = true
break
}
}
if(isFile){
res.send({ code: 0,message:"文件已生成" });
}else {
res.send({ code: 1,message:"文件未生成" });
}
})
module.exports = router;
... ...