
# Attachment Fields

The media category covers file uploads and the barcode field. `single-attachment` and `multiple-attachments` upload files into a storage bucket; `barcode` stores a scannable value (documented in detail on the [Advanced Fields](/en/docs/advanced-fields#barcode) page). All share the [base field properties](/en/docs/tables-overview#base-field-properties).

| Type                   | Stores                                                                     |
| ---------------------- | -------------------------------------------------------------------------- |
| `single-attachment`    | A single uploaded file.                                                    |
| `multiple-attachments` | Multiple uploaded files.                                                   |
| `barcode`              | A barcode value — see [Advanced Fields](/en/docs/advanced-fields#barcode). |

## `single-attachment`

One uploaded file (avatar, document, image).

| Property            | Description                                                                                                 |
| ------------------- | ----------------------------------------------------------------------------------------------------------- |
| `bucket`            | Storage bucket name. References a bucket in `app.buckets`. Uses the implicit `default` bucket when omitted. |
| `allowedFileTypes`  | Array of allowed MIME types (e.g. `["image/png", "image/jpeg"]`). All types allowed when empty.             |
| `maxFileSize`       | Maximum file size in **bytes** (integer ≥ 1). Example: `5242880` for 5 MB.                                  |
| `generateThumbnail` | Boolean. Generate image thumbnails on upload.                                                               |
| `storeMetadata`     | Boolean. Store metadata (image dimensions, video duration).                                                 |

```yaml
- id: 1
  name: avatar
  type: single-attachment
  bucket: avatars
  allowedFileTypes: [image/png, image/jpeg, image/gif]
  maxFileSize: 5242880
  generateThumbnail: true
  storeMetadata: true
```

## `multiple-attachments`

Many uploaded files (a gallery, a document set).

| Property             | Description                                                                                                                  |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `bucket`             | Storage bucket name. References a bucket in `app.buckets`. Uses `default` when omitted.                                      |
| `maxFiles`           | Maximum number of files allowed (integer ≥ 1).                                                                               |
| `allowedFileTypes`   | Array of allowed MIME types (e.g. `["application/pdf", "application/msword"]`).                                              |
| `maxFileSize`        | Maximum size in **bytes** per attachment (integer ≥ 1). Example: `10485760` for 10 MB.                                       |
| `generateThumbnails` | Boolean. Generate image thumbnails on upload. _(Note the plural — singular `generateThumbnail` is for `single-attachment`.)_ |
| `storeMetadata`      | Boolean. Store metadata for each attachment.                                                                                 |

```yaml
- id: 2
  name: documents
  type: multiple-attachments
  bucket: documents
  maxFiles: 10
  allowedFileTypes: [application/pdf, application/msword]
  maxFileSize: 10485760
  generateThumbnails: true
```

:::callout
**Buckets, not inline storage.** Attachment fields write to named buckets defined in `app.buckets` (local or S3). The `bucket` property selects which one; omitting it uses the implicit `default` bucket. `maxFileSize` is always specified in **bytes**. See the Buckets documentation for bucket configuration.
:::

The `barcode` field is the third member of the media category but is documented alongside the other specialized value fields — see [Advanced Fields → barcode](/en/docs/advanced-fields#barcode).
