mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
add a hook for plugins like nodebb-plugin-imagemagick that don't want to replace the entire upload system
This commit is contained in:
@@ -50,6 +50,13 @@ file.base64ToLocal = function(imageData, uploadPath, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
file.isFileTypeAllowed = function(path, 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
|
// Attempt to read the file, if it passes, file type is allowed
|
||||||
jimp.read(path, function(err) {
|
jimp.read(path, function(err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
@@ -95,4 +102,4 @@ file.existsSync = function(path) {
|
|||||||
return !!exists;
|
return !!exists;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = file;
|
module.exports = file;
|
||||||
|
|||||||
Reference in New Issue
Block a user