Documentation
    Preparing search index...

    The file holds the meta/data for an uploaded file, along with any errors that occurred during the upload process.

    Hierarchy

    • default
      • MultipartFile
    Index

    Constructors

    • Creates a new MultipartFile instance

      Parameters

      • data: { fieldName: string; clientName: string; headers: any }

        Object containing field name, client name, and headers

      • validationOptions: Partial<FileValidationOptions>

        Validation options for the file

      Returns MultipartFile

    Properties

    isMultipartFile: true

    A boolean to know if file is an instance of this class or not

    fieldName: string

    Field name is the name of the field

    clientName: string

    Client name is the file name on the user client

    headers: Record<string, any>

    The headers sent as part of the multipart request

    size: number = 0

    File size in bytes

    extname?: string

    The extension for the file

    errors: FileUploadError[] = []

    Upload errors that occurred during processing

    type?: string

    Type and subtype are extracted from the content-type header or from the file magic number

    subtype?: string
    filePath?: string

    File path is only set after the move operation

    fileName?: string

    File name is only set after the move operation. It is the relative path of the moved file

    tmpPath?: string

    Temporary path, only exists when file is uploaded using the classic mode

    meta: any = {}

    The file metadata

    state: "idle" | "streaming" | "consumed" | "moved" = 'idle'

    The current state of the file

    Accessors

    • get validated(): boolean

      Whether or not the validations have been executed

      Returns boolean

    • get sizeLimit(): undefined | string | number

      The maximum file size limit

      Returns undefined | string | number

    • set sizeLimit(limit: undefined | string | number): void

      Parameters

      • limit: undefined | string | number

      Returns void

    • get allowedExtensions(): undefined | string[]

      Extensions allowed

      Returns undefined | string[]

    • set allowedExtensions(extensions: undefined | string[]): void

      Parameters

      • extensions: undefined | string[]

      Returns void

    Methods

    • Mark file as moved to its final destination

      Parameters

      • fileName: string

        The name of the moved file

      • filePath: string

        The full path where the file was moved

      Returns void

    • Moves the file to a given location. Multiple calls to the move method are allowed, in case you want to move a file to multiple locations.

      Parameters

      • location: string

        The destination directory

      • Optionaloptions: { name?: string; overwrite?: boolean }

        Move options including name and overwrite flag

      Returns Promise<void>