Documentation
    Preparing search index...

    Multipart class offers a low level API to interact with the incoming HTTP request data as a stream. This makes it super easy to write files to S3 without saving them to the disk first.

    Index

    Constructors

    Properties

    Methods

    Constructors

    • Creates a new Multipart instance for processing multipart form data

      Parameters

      • ctx: HttpContext

        The HTTP context

      • config: Partial<
            {
                limit: string
                | number;
                fieldsLimit: string | number;
                maxFields: number;
                convertEmptyStringsToNull: boolean;
            },
        > = {}

        Configuration options for multipart processing

      • _featureFlags: Record<string, never> = {}

        Feature flags (unused)

      Returns Multipart

    Properties

    state: "idle" | "error" | "processing" | "success" = 'idle'

    The current state of the multipart form handler

    Methods

    • Attach handler for a given file. To handle all files, you can attach a wildcard handler.

      Parameters

      • name: string

        The field name to handle, or '*' for wildcard

      • options: Partial<FileValidationOptions & { deferValidations: boolean }>

        Validation options and configuration

      • handler: PartHandler

        The handler function to process the file

      Returns this

      multipart.onFile('package', {}, async (stream) => {
      })

      multipart.onFile('*', {}, async (stream) => {
      })
    • Abort request by emitting error

      Parameters

      • error: any

        The error that caused the abort

      Returns void

    • Process the request by going through all the file and field streams.

      Parameters

      • Optionalconfig: Partial<{ limit: string | number; maxFields: number }>

        Optional configuration overrides

      Returns Promise<void>