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.
Extends
Section titled “Extends”BaseFieldInput<TCollectionSlug,TFieldKey,TFieldMeta>
Type Parameters
Section titled “Type Parameters”TCollectionSlug
Section titled “TCollectionSlug”TCollectionSlug extends VexResourceSlug = VexResourceSlug
TFieldKey
Section titled “TFieldKey”TFieldKey extends string = never
TFieldMeta
Section titled “TFieldMeta”TFieldMeta extends BaseFieldMeta = BaseFieldMeta
Properties
Section titled “Properties”accept?
Section titled “accept?”
optionalaccept?: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
Examples
Section titled “Examples”'image/*''image/*, audio/mp4''image/webp, audio/mp3'admin?
Section titled “admin?”
optionaladmin?:FieldAdminConfigInput<TCollectionSlug,ComponentHKT>
Defined in: packages/core/src/fields/baseTypes.ts:531
Admin UI configuration for this field.
Inherited from
Section titled “Inherited from”defaultValue?
Section titled “defaultValue?”
optionaldefaultValue?:string[]
Defined in: packages/core/src/fields/upload/types.ts:48
Pre-filled value shown in the admin form when creating a new document.
Overrides
Section titled “Overrides”description?
Section titled “description?”
optionaldescription?:string
Defined in: packages/core/src/fields/baseTypes.ts:516
Semantic description of the field. Used in three places:
- Helper text rendered below the field input in the admin form UI.
- As the Zod
.meta({ description })value for form validation. - As the JSDoc comment on the generated document interface property.
To write a separate JSDoc comment, use interfaceDescription in addition.
Inherited from
Section titled “Inherited from”hasMany?
Section titled “hasMany?”
optionalhasMany?:boolean
Defined in: packages/core/src/fields/upload/types.ts:44
Whether this input accepts multiple files or only one.
index?
Section titled “index?”
optionalindex?: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.
Example
Section titled “Example”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"])Inherited from
Section titled “Inherited from”interfaceDescription?
Section titled “interfaceDescription?”
optionalinterfaceDescription?:string
Defined in: packages/core/src/fields/baseTypes.ts:518
The JSDoc comment on the generated document interface property
Inherited from
Section titled “Inherited from”BaseFieldInput.interfaceDescription
label?
Section titled “label?”
optionallabel?:string
Defined in: packages/core/src/fields/baseTypes.ts:507
Display label for the field in the admin form.
Inherited from
Section titled “Inherited from”
optionalmax?:FieldLimitInput
Defined in: packages/core/src/fields/upload/types.ts:40
Maximum number of files allowed.
optionalmeta?:TFieldMeta
Defined in: packages/core/src/fields/baseTypes.ts:546
Inherited from
Section titled “Inherited from”
optionalmin?:FieldLimitInput
Defined in: packages/core/src/fields/upload/types.ts:35
Minimum number of files allowed. Absent — the default — means no minimum.
required?
Section titled “required?”
optionalrequired?:boolean
Defined in: packages/core/src/fields/baseTypes.ts:524
Whether this field is required.
Default: false
Inherited from
Section titled “Inherited from”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.
Example
Section titled “Example”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`