Skip to content

UploadFieldInput

Defined in: packages/core/src/fields/upload/types.ts:10

Input configuration for an upload() field — the to parameter is required and references the target media collection slug.

TCollectionSlug extends VexResourceSlug = VexResourceSlug

TFieldKey extends string = never

TFieldMeta extends BaseFieldMeta = BaseFieldMeta

optional accept?: string

Defined in: packages/core/src/fields/upload/types.ts:56

Restrict files that can be uploaded by mimeType.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/accept

'image/*'
'image/*, audio/mp4'
'image/webp, audio/mp3'

optional admin?: FieldAdminConfigInput<TCollectionSlug, ComponentHKT>

Defined in: packages/core/src/fields/baseTypes.ts:531

Admin UI configuration for this field.

BaseFieldInput.admin


optional defaultValue?: string[]

Defined in: packages/core/src/fields/upload/types.ts:48

Pre-filled value shown in the admin form when creating a new document.

BaseFieldInput.defaultValue


optional description?: string

Defined in: packages/core/src/fields/baseTypes.ts:516

Semantic description of the field. Used in three places:

  1. Helper text rendered below the field input in the admin form UI.
  2. As the Zod .meta({ description }) value for form validation.
  3. As the JSDoc comment on the generated document interface property.

To write a separate JSDoc comment, use interfaceDescription in addition.

BaseFieldInput.description


optional hasMany?: boolean

Defined in: packages/core/src/fields/upload/types.ts:44

Whether this input accepts multiple files or only one.


optional index?: FieldIndexConfigInput<TCollectionSlug, TFieldKey>

Defined in: packages/core/src/fields/baseTypes.ts:545

Create a database index on this field. The string value becomes the index name in Convex.

slug: { type: "text", index: "by_slug", required: true }
// Generates: .index("by_slug", ["slug"])
author: { type: "relationship", index: { name: "by_author_status", additionalFields: ["status"] } }
// Generates: .index("by_author_status", ["author", "status"])

BaseFieldInput.index


optional interfaceDescription?: string

Defined in: packages/core/src/fields/baseTypes.ts:518

The JSDoc comment on the generated document interface property

BaseFieldInput.interfaceDescription


optional label?: string

Defined in: packages/core/src/fields/baseTypes.ts:507

Display label for the field in the admin form.

BaseFieldInput.label


optional max?: FieldLimitInput

Defined in: packages/core/src/fields/upload/types.ts:40

Maximum number of files allowed.

FieldLimitInput


optional meta?: TFieldMeta

Defined in: packages/core/src/fields/baseTypes.ts:546

BaseFieldInput.meta


optional min?: FieldLimitInput

Defined in: packages/core/src/fields/upload/types.ts:35

Minimum number of files allowed. Absent — the default — means no minimum.

FieldLimitInput


optional required?: boolean

Defined in: packages/core/src/fields/baseTypes.ts:524

Whether this field is required.

Default: false

BaseFieldInput.required


to: string

Defined in: packages/core/src/fields/upload/types.ts:30

The slug of the media collection that stores uploaded files for this field.

Must match a media collection defined via a storage adapter’s defineMediaCollection(). After running vex generate, this is typed as MediaCollectionSlug — a union of all media collection slugs in the project. Before generation, it falls back to string.

Config validation (in media/config.ts) also checks at runtime that the slug exists in VexConfig.mediaCollections.

upload({ to: "images", label: "Featured Image" })
## Methods
### validate()?
> `optional` **validate**(`props`): `void` \| `Promise`\<`void`\>
Defined in: packages/core/src/fields/upload/types.ts:58
Server-only async validation with `value` typed as `string[]`.
#### Parameters
##### props
[`FieldValidateProps`](/api/core/src/interfaces/fieldvalidateprops/)\<`TCollectionSlug`, `string`[]\>
#### Returns
`void` \| `Promise`\<`void`\>
#### See
[FieldValidate](/api/core/src/type-aliases/fieldvalidate/)
#### Overrides
`BaseFieldInput.validate`