lukeautry / tsoa

Build OpenAPI-compliant REST APIs using TypeScript and Node
MIT License
3.59k stars 504 forks source link

how to change multer filesize config #1556

Closed midoelhawy closed 9 months ago

midoelhawy commented 9 months ago

it Possible to change multer max file size directly from tsoa.json to avoid "MulterError: File too large" Error ?

lewatt23 commented 5 months ago

@midoelhawy please did you find a solution ?

midoelhawy commented 5 months ago

@midoelhawy please did you find a solution ?

Hi @lewatt23 Yes, you need to add multer configuration in your tsoa.json like this:

{
  "entryFile": "./src/main.ts",
  "noImplicitAdditionalProperties": "throw-on-extras",
  "controllerPathGlobs": ["./src/controllers/*/*.ts", "./src/controllers/*.ts"],

  "spec": {
    "specVersion": 3,
    "outputDirectory": ".",
    "securityDefinitions": {
      "jwt": {
        "description": "JSONWebToken (JWT) authorization",
        "bearerFormat": "JWT",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },

  "routes": {
    "basePath": "/",
    "routesDir": "./src",
    "middleware": "express",
    "authenticationModule": "./src/authentication.ts"
  },

  "multerOpts": {
    "limits": {
      "fileSize": 31457280
    }
  }
}
lewatt23 commented 5 months ago

Thanks so much.