From f5009b1a1191298aa8f30e40069c4fa66696b322 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Thu, 21 Apr 2016 14:09:10 -0500 Subject: [PATCH] add a hook for plugins like nodebb-plugin-imagemagick that don't want to replace the entire upload system --- src/file.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/file.js b/src/file.js index 1c1cab7781..001e1324cb 100644 --- a/src/file.js +++ b/src/file.js @@ -50,6 +50,13 @@ file.base64ToLocal = function(imageData, uploadPath, callback) { }; file.isFileTypeAllowed = function(path, callback) { + var plugins = require('./plugins'); + if (plugins.hasListeners('filter:file.isFileTypeAllowed')) { + return plugins.fireHook('filter:file.isFileTypeAllowed', path, function(err) { + callback(err); + }); + } + // Attempt to read the file, if it passes, file type is allowed jimp.read(path, function(err) { callback(err); @@ -95,4 +102,4 @@ file.existsSync = function(path) { return !!exists; }; -module.exports = file; \ No newline at end of file +module.exports = file;