From 20d789f2e6a7e446cace76668dfe890458485170 Mon Sep 17 00:00:00 2001 From: Holly Date: Fri, 7 Jan 2022 06:17:20 +0000 Subject: [PATCH] Fix filename fetching in line with busboy changes --- EUS.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/EUS.js b/EUS.js index 942df2d..9502ece 100644 --- a/EUS.js +++ b/EUS.js @@ -325,14 +325,15 @@ module.exports = { var thefe; // Pipe the request to busboy req.pipe(req.busboy); - req.busboy.on('file', function (fieldname, file, filename) { + req.busboy.on('file', function (fieldname, file, info) { // Make a new file name fileOutName = randomstring.generate(14); global.modules.consoleHelper.printInfo(emoji.fast_up, `${req.method}: Upload of ${fileOutName} started.`); - // Check the file is within the accepted file types - if (eusConfig.acceptedTypes.includes(`.${filename.split(".")[filename.split(".").length-1]}`)) { + // Check the file is within the accepted file types + const fileType = info.filename.split(".").slice(-1); + if (eusConfig.acceptedTypes.includes(`.${fileType}`)) { // File is accepted, set the extention of the file in thefe for later use. - thefe = `${filename.split(".")[filename.split(".").length-1]}`; + thefe = fileType; } else { // File isn't accepted, send response back to client stating so. res.status(403).end("This file type isn't accepted currently.");