export class FormDataTestDto {
@IsInt()
@ApiProperty({ example: "1" })
@Transform(({ value }) => Number(value))
id: number;
@IsFile()
@HasMimeType(['text/plain'])
@ApiProperty({ type: "string", format: "binary", required: false })
@MaxFileSize(5)
@MinFileSize(3)
@IsOptional()
file?: MemoryStoredFile;
}
If there is no file provided in form data I get error:
[00:29:29.937] ERROR (46218): Multipart: Boundary not found {"req":{"id":"req-3","method":"POST","url":"/auth/test-form-data"},"context":"ExceptionsFilter"}
err: {
"type": "Error",
"message": "Multipart: Boundary not found",
"stack":
Error: Multipart: Boundary not found
at new Multipart (/Users/eliassmith/Dev/Projects/bazaar-be/node_modules/busboy/lib/types/multipart.js:233:13)
at getInstance (/Users/eliassmith/Dev/Projects/bazaar-be/node_modules/busboy/lib/index.js:33:12)
at module.exports (/Users/eliassmith/Dev/Projects/bazaar-be/node_modules/busboy/lib/index.js:56:10)
at new FormReader (/Users/eliassmith/Dev/Projects/bazaar-be/node_modules/nestjs-form-data/src/classes/FormReader.ts:22:25)
at FormDataInterceptor.intercept (/Users/eliassmith/Dev/Projects/bazaar-be/node_modules/nestjs-form-data/src/interceptors/FormData.interceptor.ts:51:36)
at nextFn (/Users/eliassmith/Dev/Projects/bazaar-be/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:23:36)
at /Users/eliassmith/Dev/Projects/bazaar-be/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:21:88
at AsyncResource.runInAsyncScope (node:async_hooks:213:14)
at bound (node:async_hooks:244:16)
at Observable._subscribe (/Users/eliassmith/Dev/Projects/bazaar-be/node_modules/rxjs/src/internal/observable/defer.ts:54:15)
}
If there is no file provided in form data I get error: