Fix FileUploadMiddleware formidable usage
This commit is contained in:
parent
2e68cf8cae
commit
e151c9c744
@ -1,16 +1,16 @@
|
||||
import {NextFunction, Request, Response} from "express";
|
||||
import IncomingForm from "formidable/Formidable.js";
|
||||
import formidable, {Options} from "formidable";
|
||||
|
||||
import {FileError, ValidationBag} from "./db/Validator.js";
|
||||
import Middleware from "./Middleware.js";
|
||||
|
||||
export default abstract class FileUploadMiddleware extends Middleware {
|
||||
protected abstract makeForm(): IncomingForm;
|
||||
protected abstract getFormidableOptions(): Options;
|
||||
|
||||
protected abstract getDefaultField(): string;
|
||||
|
||||
public async handle(req: Request, res: Response, next: NextFunction): Promise<void> {
|
||||
const form = this.makeForm();
|
||||
const form = formidable(this.getFormidableOptions());
|
||||
try {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
form.parse(req, (err, fields, files) => {
|
||||
|
Loading…
Reference in New Issue
Block a user