# MulterField

**Kind:** Interface

**Source:** [`packages/platform-express/multer/interfaces/multer-options.interface.ts`](https://github.com/nestjs/nest/blob/master/packages/platform-express/multer/interfaces/multer-options.interface.ts#L66)

**Part of:** [Platform Express](subsystem-packages-platform-express)

`MulterField` defines a named multipart form-data field accepted by NestJS's Multer integration. It is typically used when configuring file upload interceptors that accept multiple named file fields, with `maxCount` limiting how many files each field may contain.

## Properties

| Property | Type |
|---|---|
| `name` | `string` |
| `maxCount` | `number` |

## Diagram

```mermaid
graph LR
  Client[Multipart Request] --> Interceptor[FileFieldsInterceptor]
  Interceptor --> Field[MulterField]
  Field --> Name["name: field identifier"]
  Field --> MaxCount["maxCount: maximum files"]
  Interceptor --> Uploads[Uploaded file arrays]
```

## Usage

```ts
import { Controller, Post, UploadedFiles, UseInterceptors } from '@nestjs/common';
import { FileFieldsInterceptor } from '@nestjs/platform-express';
import type { MulterField } from '@nestjs/platform-express/multer/interfaces/multer-options.interface';

const uploadFields: MulterField[] = [
  { name: 'avatar', maxCount: 1 },
  { name: 'documents', maxCount: 5 },
];

@Controller('uploads')
export class UploadController {
  @Post()
  @UseInterceptors(FileFieldsInterceptor(uploadFields))
  uploadFiles(
    @UploadedFiles()
    files: {
      avatar?: Express.Multer.File[];
      documents?: Express.Multer.File[];
    },
  ) {
    return {
      avatar: files.avatar?.[0],
      documents: files.documents ?? [],
    };
  }
}
```

## AI Coding Instructions

- Use `name` values that exactly match the multipart form field names sent by clients.
- Set `maxCount` to the intended per-field upload limit; use `1` for single-file fields.
- Pass `MulterField[]` to `FileFieldsInterceptor` when an endpoint accepts several differently named file fields.
- Remember that uploaded files are returned as arrays per field, including fields configured with `maxCount: 1`.
- Configure Multer validation, storage, and file-size limits separately through interceptor options or module configuration.
