Documentation
    Preparing search index...

    Namespace TypedFormData

    Type safe multipart/form-data decorator.

    TypedFormData.Body() is a request body decorator function for the multipart/form-data content type. It automatically casts property type following its DTO definition, and performs the type validation too.

    Also, TypedFormData.Body() is much easier and type safer than @nest.UploadFile(). If you're considering the SDK library generation, only TypedFormData.Body() can do it. Therefore, I recommend you to use TypedFormData.Body() instead of the @nest.UploadFile() function.

    For reference, target type T must follow such restriction. Of course, if actual form-data values are different with their promised type T, BadRequestException error (status code: 400) would be thrown.

    1. Type T must be an object type
    2. Do not allow dynamic property
    3. Only boolean, bigint, number, string, Blob, File or their array types are allowed
    4. By the way, union type never be not allowed

    By the way, if you're using fastify, you have to setup fastify-multer and configure like below when composing the NestJS application. If you don't do that, @TypedFormData.Body() will not work properly, and throw 500 internal server error when Blob or File type being utilized.

    import { NestFactory } from "@nestjs/core";
    import {
    FastifyAdapter,
    NestFastifyApplication,
    } from "@nestjs/platform-fastify";
    import fastifyMulter from "fastify-multer";

    export async function main() {
    const app = await NestFactory.create<NestFastifyApplication>(
    AppModule,
    new FastifyAdapter(),
    );
    app.register(fastifyMulter.contentParser);
    await app.listen(3000);
    }

    Jeongho Nam - https://github.com/samchon

    Change to ReadableStream through configuring storage engine of multer

    IMulterBase