From b15701dd7caabfb0d94839929a2b8280e0eb6403 Mon Sep 17 00:00:00 2001 From: relsoul Date: Mon, 12 Jun 2023 16:49:06 +0800 Subject: [PATCH] Fix file exists but file name does not exist --- lib/make-middleware.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/make-middleware.js b/lib/make-middleware.js index b033cbd9..12a90a51 100644 --- a/lib/make-middleware.js +++ b/lib/make-middleware.js @@ -96,7 +96,15 @@ function makeMiddleware (setup) { // handle files busboy.on('file', function (fieldname, fileStream, filename, encoding, mimetype) { // don't attach to the files object, if there is no file - if (!filename) return fileStream.resume() + if (!filename) { + // @link https://github.com/mscdex/busboy/blob/master/lib/types/multipart.js + // If the type is 'application/octet-stream', it is also identified as a file + if(mimetype==='application/octet-stream'){ + filename = 'unknownFile' + }else{ + return fileStream.resume() + } + } // Work around bug in Busboy (https://github.com/mscdex/busboy/issues/6) if (limits && Object.prototype.hasOwnProperty.call(limits, 'fieldNameSize')) {