# MulterFileSize Decorator

Module
import { MulterFileSize } from "@tsed/multipartfiles"
Source/packages/multipartfiles/src/decorators/multerFileSize.ts

# Overview

function MulterFileSize(fileSize: number): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;

# Description

Define file size limit.

import {Controller, Post} from "@tsed/common";
import {MulterOptions, MultipartFile} from "@tsed/multipartfiles";
import {Multer} from "@types/multer";

type MulterFile = Express.Multer.File;

@Controller('/')
class MyCtrl {
  @Post('/file2')
  @MulterFileSize(1024) // (Ko). Applied for all fields
  private uploadFile(@MultipartFile("file1") file: MulterFile, @MultipartFile("file2") file2: MulterFile) {

  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

See the tutorial on the multer configuration.