aboutsummaryrefslogtreecommitdiff
path: root/controllers/uploadController.js
diff options
context:
space:
mode:
authorKanacchi <[email protected]>2017-03-28 00:00:08 +0200
committerGitHub <[email protected]>2017-03-28 00:00:08 +0200
commit3e38e138ca5b39d1b94e0b536fe44e322836f82f (patch)
tree9273627f5f8466facc12b3685765410a79d441cb /controllers/uploadController.js
parentMerge pull request #21 from RyoshiKayo/patch-2 (diff)
parentadded array with blocked file extensions (diff)
downloadhost.fuwn.me-3e38e138ca5b39d1b94e0b536fe44e322836f82f.tar.xz
host.fuwn.me-3e38e138ca5b39d1b94e0b536fe44e322836f82f.zip
Merge pull request #22 from Onestay/onestay
added array with blocked file extensions
Diffstat (limited to 'controllers/uploadController.js')
-rw-r--r--controllers/uploadController.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/controllers/uploadController.js b/controllers/uploadController.js
index 39a9364..d9ca04e 100644
--- a/controllers/uploadController.js
+++ b/controllers/uploadController.js
@@ -20,7 +20,13 @@ const storage = multer.diskStorage({
const upload = multer({
storage: storage,
- limits: { fileSize: config.uploads.maxSize }
+ limits: { fileSize: config.uploads.maxSize },
+ fileFilter: function(req, file, cb) {
+ if (config.blockedExtensions.some((extension) => { return path.extname(file.originalname) === extension; })) {
+ return cb('This file extension is not allowed');
+ }
+ return cb(null, true);
+ }
}).array('files[]')
uploadsController.upload = function(req, res, next) {