From 2797c504b4dd12d9220a790cf18d092485a769a7 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 27 Oct 2020 19:46:43 -0600 Subject: [PATCH] download mp3 --- .../sermon-large/sermon-large.component.html | 2 +- Server/src/routes/api/sermons.js | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Client/src/app/components/sermon-large/sermon-large.component.html b/Client/src/app/components/sermon-large/sermon-large.component.html index 43703a3..0fdaabc 100644 --- a/Client/src/app/components/sermon-large/sermon-large.component.html +++ b/Client/src/app/components/sermon-large/sermon-large.component.html @@ -8,7 +8,7 @@
{{ description }}
file_download Download
diff --git a/Server/src/routes/api/sermons.js b/Server/src/routes/api/sermons.js index 42d9cc6..0f8a10a 100644 --- a/Server/src/routes/api/sermons.js +++ b/Server/src/routes/api/sermons.js @@ -64,14 +64,11 @@ router.get("/download/:id",function(req,res){ return; } var file = finalStorage + sermon.file; - console.log(file); - file = 'https://static.danabsher.com/media/' + 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"}); - // } + if (fs.existsSync(file)){ + res.download(file); + } else { + res.status(404).json({"status":404,"message":"Could not find the file associated with this sermon"}); + } }); });