@tiledesk/tiledesk-server 2.3.101 → 2.3.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/routes/images.js +12 -2
package/package.json
CHANGED
package/routes/images.js
CHANGED
@@ -431,14 +431,24 @@ router.get("/", async (req, res) => {
|
|
431
431
|
}
|
432
432
|
|
433
433
|
|
434
|
-
|
434
|
+
try {
|
435
435
|
let file = await fileService.find(req.query.path);
|
436
436
|
// console.log("file", file);
|
437
437
|
|
438
438
|
res.set({ "Content-Length": file.length});
|
439
439
|
res.set({ "Content-Type": file.contentType});
|
440
440
|
|
441
|
-
|
441
|
+
} catch (e) {
|
442
|
+
if (e.code == "ENOENT") {
|
443
|
+
winston.debug('Image not found: '+req.query.path);
|
444
|
+
return res.status(404).send({success: false, msg: 'Image not found.'});
|
445
|
+
}else {
|
446
|
+
winston.error('Error getting the image', e);
|
447
|
+
return res.status(500).send({success: false, msg: 'Error getting image.'});
|
448
|
+
}
|
449
|
+
}
|
450
|
+
|
451
|
+
fileService.getFileDataAsStream(req.query.path).on('error', (e)=> {
|
442
452
|
if (e.code == "ENOENT") {
|
443
453
|
winston.debug('Image not found: '+req.query.path);
|
444
454
|
return res.status(404).send({success: false, msg: 'Image not found.'});
|