From 60fae4be9f82b5b287c8411762e29291726c46d3 Mon Sep 17 00:00:00 2001 From: Iran-110 <70788031+Iran-110@users.noreply.github.com> Date: Mon, 15 Mar 2021 17:00:00 +0330 Subject: [PATCH] Inject `form` to `multipartHandler` functions Injecting formidable `form` to `multipartHandler` and `multipartFileHandler` functions as the third argument can give us the ability to call `form.handlePart(part)` inside the customized functions. It's useful when the user wants to restrict input files to some extensions e.g. png/jpg/jpeg etc. As a result, when the `part.mime` would be acceptable, the user can continue the process. --- lib/plugins/multipartBodyParser.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plugins/multipartBodyParser.js b/lib/plugins/multipartBodyParser.js index c94a90776..a5570a37a 100644 --- a/lib/plugins/multipartBodyParser.js +++ b/lib/plugins/multipartBodyParser.js @@ -80,9 +80,9 @@ function multipartBodyParser(options) { form.onPart = function onPart(part) { if (part.filename && opts.multipartFileHandler) { - opts.multipartFileHandler(part, req); + opts.multipartFileHandler(part, req, form); } else if (!part.filename && opts.multipartHandler) { - opts.multipartHandler(part, req); + opts.multipartHandler(part, req, form); } else { form.handlePart(part); }