Fix garbled non English chars on document upload (#3301)

update handleAPIFileUpload middleware to handle non english chars + update jsdoc
This commit is contained in:
Sean Hatfield 2025-02-21 15:09:34 +08:00 committed by GitHub
parent dec13beb6e
commit c36df2c364
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 8 deletions

View File

@ -35,14 +35,15 @@ function apiDocumentEndpoints(app) {
content: {
"multipart/form-data": {
schema: {
type: 'string',
format: 'binary',
type: 'object',
properties: {
file: {
type: 'string',
format: 'binary',
description: 'The file to upload'
}
}
},
required: ['file']
}
}
}

View File

@ -900,14 +900,17 @@
"content": {
"multipart/form-data": {
"schema": {
"type": "string",
"format": "binary",
"type": "object",
"properties": {
"file": {
"type": "string",
"format": "binary"
"format": "binary",
"description": "The file to upload"
}
}
},
"required": [
"file"
]
}
}
}

View File

@ -37,7 +37,9 @@ const fileAPIUploadStorage = multer.diskStorage({
cb(null, uploadOutput);
},
filename: function (_, file, cb) {
file.originalname = normalizePath(file.originalname);
file.originalname = normalizePath(
Buffer.from(file.originalname, "latin1").toString("utf8")
);
cb(null, file.originalname);
},
});