From 5d09892ec1424c62df5a794023f95dd051beda7f Mon Sep 17 00:00:00 2001 From: Pitu Date: Thu, 19 Jan 2017 03:04:22 -0300 Subject: [PATCH] Ohboi --- controllers/uploadController.js | 4 +++- routes/api.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/controllers/uploadController.js b/controllers/uploadController.js index 499bdb7..8f4b092 100644 --- a/controllers/uploadController.js +++ b/controllers/uploadController.js @@ -26,7 +26,7 @@ uploadsController.upload = function(req, res, next){ if(req.headers.auth !== config.clientToken) return res.status(401).json({ success: false, description: 'not-authorized'}) - let album = req.body.album + let album = req.params.albumid if(album !== undefined) if(req.headers.adminauth !== config.adminToken) @@ -41,6 +41,8 @@ uploadsController.upload = function(req, res, next){ }) } + if(req.files.length === 0) return res.json({ success: false, description: 'no-files' }) + let files = [] req.files.forEach(function(file) { files.push({ diff --git a/routes/api.js b/routes/api.js index 4333c74..b7c4453 100644 --- a/routes/api.js +++ b/routes/api.js @@ -13,6 +13,7 @@ routes.get ('/check', (req, res, next) => { routes.get ('/uploads', (req, res, next) => uploadController.list(req, res)) routes.post ('/upload', (req, res, next) => uploadController.upload(req, res, next)) +routes.post ('/upload/:albumid', (req, res, next) => uploadController.upload(req, res, next)) routes.get ('/album/:id', (req, res, next) => uploadController.list(req, res, next)) routes.get ('/albums', (req, res, next) => albumsController.list(req, res, next))