From 17b3c5e4cd6a09fc2539d445c6c821f058f9eda2 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 29 Sep 2017 14:36:31 -0600 Subject: [PATCH] File download issues --- Server/src/routes/api/sermons.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Server/src/routes/api/sermons.js b/Server/src/routes/api/sermons.js index 3247e51..16f0e95 100644 --- a/Server/src/routes/api/sermons.js +++ b/Server/src/routes/api/sermons.js @@ -64,7 +64,12 @@ router.get("/download/:id",function(req,res){ return; } var file = finalStorage + sermon.file; - res.download(file); + if (fs.existsSync(file)){ + res.download(file); + } else { + res.status(404).json({"status":404,"message":"Could not find the file associated with this sermon"}); + } + }); });