Use new FileUploadMiddleware

This commit is contained in:
Alice Gaudon 2020-07-11 11:19:39 +02:00
parent d5bef2e83f
commit b9482e9c41

View File

@ -7,9 +7,9 @@ import config from "config";
import * as fs from "fs";
import AuthToken from "../models/AuthToken";
import {IncomingForm} from "formidable";
import {FILE_UPLOAD_MIDDLEWARE} from "wms-core/components/ExpressAppComponent";
import generateSlug from "../SlugGenerator";
import Logger from "wms-core/Logger";
import FileUploadMiddleware from "wms-core/FileUploadMiddleware";
export default class FileController extends Controller {
@ -122,8 +122,7 @@ export default class FileController extends Controller {
}
}
export const FILE_UPLOAD_FORM_MIDDLEWARE = FILE_UPLOAD_MIDDLEWARE(() => {
export const FILE_UPLOAD_FORM_MIDDLEWARE = new FileUploadMiddleware(() => {
const form = new IncomingForm();
form.uploadDir = 'storage/tmp';
form.maxFileSize = config.get<number>('max_upload_size') * 1024 * 1024;