fix viewimg 404 status
This commit is contained in:
parent
bcc4b1ed7d
commit
0cd5667f63
6
app.js
6
app.js
@ -66,7 +66,7 @@ app.get('/camevent', (req, res) => {
|
|||||||
app.get('/viewcamimg/:dir/:img', async(req, res) => {
|
app.get('/viewcamimg/:dir/:img', async(req, res) => {
|
||||||
let dir = req.params.dir;
|
let dir = req.params.dir;
|
||||||
let img = req.params.img;
|
let img = req.params.img;
|
||||||
if (!dir || !img) return res.status(404).end();
|
if (!dir || !img) return res.sendStatus(404);
|
||||||
try {
|
try {
|
||||||
let stat = await new Promise((resolve, reject) => {
|
let stat = await new Promise((resolve, reject) => {
|
||||||
fs.stat(path.resolve(config.cmdpath.ipcamsave, dir, img), (err, stats) => {
|
fs.stat(path.resolve(config.cmdpath.ipcamsave, dir, img), (err, stats) => {
|
||||||
@ -74,9 +74,9 @@ app.get('/viewcamimg/:dir/:img', async(req, res) => {
|
|||||||
return resolve(stats);
|
return resolve(stats);
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
if (!stat.isFile()) return res.status(404).end();
|
if (!stat.isFile()) return res.sendStatus(404);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return res.status(404).end();
|
return res.sendStatus(404);
|
||||||
}
|
}
|
||||||
res.sendfile(path.resolve(config.cmdpath.ipcamsave, dir, img))
|
res.sendfile(path.resolve(config.cmdpath.ipcamsave, dir, img))
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user