# File schema

Learn how to define schemas for uploaded files.

File schemas represent URLs to uploaded files, such as images, music, or video files.

![File input](/assets/reference/content/schema/file.png)

In the user interface, a file schema appears as a file uploader.

## Examples

Below are some examples of file schemas:

**Basic**

```json
{
  "type": "reference",
  "id": "@croct/file",
  "properties": {}
}
```

**Constraints**

```json
{
  "type": "reference",
  "id": "@croct/file",
  "properties": {
    "allowedTypes": ["image/png", "image/jpeg"],
    "minimumSize": 1024,
    "maximumSize": 1048576
  }
}
```

Unlike other schemas, the file schema is not a separate type. Instead, it is an extension of the [text schema](/reference/content/schema/types/text) with additional validation for file uploads. That is why you reference it using the `@croct/file` identifier instead of defining it directly.

## Properties

These are the properties available for file schemas:

- `allowedTypes`: `Array<string>` (optional) (default: any type from the table below)

  The allowed file types, represented as MIME types.

  For example, if you only want to allow PNG and JPEG images, you can set this property to `["image/png", "image/jpeg"]`.

  Below is a table with the file types that are currently supported:

  | File type          | Extensions                     |
  | ------------------ | ------------------------------ |
  | `image/png`        | png                            |
  | `image/jpeg`       | jpe, jpeg, jpg                 |
  | `image/jp2`        | jp2, jpg2                      |
  | `image/webp`       | webp                           |
  | `image/gif`        | gif                            |
  | `image/svg+xml`    | svg, svgz                      |
  | `image/avif`       | avif                           |
  | `video/mp4`        | mp4, mp4v, mpg4                |
  | `video/quicktime`  | mov, qt                        |
  | `video/x-webm`     | webm                           |
  | `audio/mpeg`       | m2a, m3a, mp2, mp2a, mp3, mpga |
  | `audio/mp4`        | mp4, mp4a                      |
  | `audio/wav`        | wav                            |
  | `audio/x-wav`      | wav                            |
  | `audio/x-ms-wma`   | wma                            |
  | `audio/ogg`        | oga, ogg, opus, spx            |
  | `audio/aac`        | adts, aac                      |
  | `application/json` | json                           |
  | `text/plain`       | txt                            |

- `minimumSize`: `number` (optional) (default: no minimum)

  The minimum file size in bytes, inclusive. For example, to allow only files larger than 10KB, set this property to 10240.

- `maximumSize`: `number` (optional) (default: 5242880 bytes (5MB))

  The maximum file size in bytes, inclusive. For example, to allow only files smaller than 1MB, set this property to 1048576.

  > **Maximum file size**
  >
  > The maximum file size is limited to 5MB, or 5242880 bytes.
