From 93b7945d2b2a4591797b668f91aab223d1b2daa9 Mon Sep 17 00:00:00 2001 From: Paul Bienkowski Date: Sun, 13 Dec 2020 20:46:52 +0100 Subject: [PATCH] feat: add /tracks/:track/download route --- src/routes/api/tracks.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/routes/api/tracks.js b/src/routes/api/tracks.js index 40bc717..a63e2e9 100644 --- a/src/routes/api/tracks.js +++ b/src/routes/api/tracks.js @@ -359,4 +359,17 @@ router.get( }), ); +// download the original file +router.get( + '/:track/download', + auth.optional, + wrapRoute(async (req, res) => { + if (!req.track.isVisibleTo(req.user)) { + return res.sendStatus(403); + } + + return res.sendFile(req.track.fullOriginalFilePath) + }), +); + module.exports = router;