upload
upload<
TFieldMeta>(options):UploadField<TFieldMeta>
Defined in: packages/core/src/fields/upload/config.ts:25
Creates an upload field that stores a reference to a media document.
The to parameter specifies which media collection receives uploaded files.
At config validation time, the to slug is checked against the media
collections returned by all configured storage adapters.
Type Parameters
Section titled “Type Parameters”TFieldMeta
Section titled “TFieldMeta”TFieldMeta extends BaseFieldMeta = BaseFieldMeta
Parameters
Section titled “Parameters”options
Section titled “options”UploadFieldInput<TFieldMeta>
— Upload field configuration. to is required.
Returns
Section titled “Returns”UploadField<TFieldMeta>
Resolved upload field definition.
Throws
Section titled “Throws”If to is empty or not a valid slug (/^[a-zA-Z][a-zA-Z0-9_-]*$/).
Example
Section titled “Example”defineCollection({ fields: { featuredImage: upload({ to: "images", label: "Featured Image" }), },});