Before using the @MultipartFile() you must install multer and @tsed/multipartfile module on your project:

npm install --save multer @types/multer @tsed/multipartfiles

Configure the File upload directory

By default the directory used is ${projetRoot}/uploads. You can configure another directory on your ServerLoader settings.

import {ServerLoader, ServerSettings} from "@tsed/common";
import "@tsed/multipartfiles";
import Path = require("path");
const rootDir = Path.resolve(__dirname);

   mount: {
      '/rest': `${rootDir}/controllers/**/**.js`
   uploadDir: `${rootDir}/custom-dir`,
   componentsScan: [
   multer: {
       // see multer options
export class Server extends ServerLoader {



  • dest (string): The destination directory for the uploaded files.
  • storage (StoreEngine): The storage engine to use for uploaded files.
  • limits (Object): An object specifying the size limits of the following optional properties. This object is passed to busboy directly, and the details of properties can be found on
    • fieldNameSize (number): Max field name size (Default: 100 bytes).
    • fieldSize (number): Max field value size (Default: 1MB).
    • fields (number): Max number of non- file fields (Default: Infinity).
    • fileSize (number): For multipart forms, the max file size (in bytes)(Default: Infinity).
    • files (number): For multipart forms, the max number of file fields (Default: Infinity).
    • parts (number): For multipart forms, the max number of parts (fields + files)(Default: Infinity).
    • headerPairs (number): For multipart forms, the max number of header key => value pairs to parse Default: 2000(same as node's http).
    • preservePath (boolean): Keep the full path of files instead of just the base name (Default: false).


Ts.ED use multer to handler file uploads. Single file can be injected like this:

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

class MyCtrl {
  private uploadFile(@MultipartFile('file') file: Express.Multer.File) {

  @MulterOptions({dest: "/other-dir"})
  private uploadFile(@MultipartFile('file') file: Express.Multer.File) {

For multiple files, just add Array type annotation like this:

import {Controller, Post} from "@tsed/common";
import {MultipartFile} from "@tsed/multipartfiles";

class MyCtrl {
  private uploadFile(@MultipartFile("files", 4) files: Express.Multer.File[]) {
    // multiple files with 4 as limits


Swagger spec (v2.0) doesn't support multiple files.


You can find a working example on Multer here.