Feat: Set variable type for request.file

This commit is contained in:
unitwk@outlook.com 2023-05-18 16:40:32 +08:00
parent c23648f201
commit 5764763587

View File

@ -63,10 +63,10 @@ router.post("/upload/:key", async (ctx) => {
const uploadDir = mission.parameter.uploadDir;
const cwd = instance.config.cwd;
const file = ctx.request.files.file as any;
if (file) {
const file = ctx.request.files.file;
if (file && !(file instanceof Array)) {
// Confirm storage location
const fullFileName = file.name as string;
const fullFileName = file.name;
const fileSaveRelativePath = path.normalize(path.join(uploadDir, fullFileName));
// File name special character filtering (to prevent any cross-directory intrusion)