Uploads
All upload fields automatically upload files to S3 and save url to given field. If file has more parameters (such as size, type, width, etc.) they will be saved too.
Any file repeater
The AnyFileRepeater component renders a repeater field for uploading any file.
Any upload field
The AnyUploadField component renders a file upload field for uploading any file.
- Component - simple
- Component - advanced
- API schema
This advanced upload field is a bit more complex than the Simple component. It has a label, a description, a file name, a file size, a file type, a width and a height. It also has a custom accept mime types.
export class File {
  url = def.stringColumn()
  description = def.stringColumn()
  name = def.stringColumn()
  size = def.stringColumn()
  type = def.stringColumn()
  width = def.intColumn()
  height = def.intColumn()
}
Props
| Prop | Description | 
|---|---|
| 
 | string The name of the column in Contember schema where to store file url. Required | 
| 
 | ReactNode The label for the field. Required | 
| 
 | ReactNode The description for the field. | 
| 
 | undefined | string The name of the column in Contember schema where to store file name. | 
| 
 | undefined | string The name of the column in Contember schema where to store file size. | 
| 
 | undefined | string The name of the column in Contember schema where to store file type. | 
| 
 | undefined | boolean = true If true, the field allows adding new options. | 
| 
 | undefined | ((options: AcceptFileOptions) => boolean | Promise A function that is called to check if the file is accepted. | 
| 
 | undefined | string | string[] Accepted mime types. | 
Audio file repeater
The AudioFileRepeater component renders a file repeater field for uploading audio files.
- Component - simple
- Component - advanced
- API schema
<ImageFileRepeater
  field="songs"
  urlField="song.url"
  label="Album"
  sortableBy="order"
/>
<ImageFileRepeater
  field="songs"
  urlField="song.url"
  label="Album"
  description="song.description"
  fileSizeField="song.size"
  fileTypeField="song.type"
  sortableBy="order"
>
  <TextField field="song.description" label="Description" />
</ImageFileRepeater>
export class Album {
  songs = def.oneHasMany(Song, "album");
}
export class Song {
  order = def.intColumn().notNull();
  url = def.stringColumn();
  description = def.stringColumn();
  height = def.stringColumn();
  width = def.stringColumn();
  size = def.stringColumn();
  type = def.stringColumn();
  album = def.manyHasOne(Album, "songs");
}
Props
| Prop | Description | 
|---|---|
| 
 | string The name of the column in Contember schema where to store data. Required | 
| 
 | string The name of the column in Contember schema where to store file url. Required | 
| 
 | ReactNode The label for the field. Required | 
| 
 | undefined | string The name of the column in Contember schema that is used to sort the options. | 
| 
 | undefined | string The name of the column in Contember schema that is used to order the options. | 
| 
 | ReactNode The description for the field. | 
| 
 | undefined | string The name of the column in Contember schema where to store file name. | 
| 
 | undefined | string The name of the column in Contember schema where to store file size. | 
| 
 | undefined | string The name of the column in Contember schema where to store file type. | 
| 
 | undefined | string The name of the column in Contember schema where to store height. | 
| 
 | undefined | string The name of the column in Contember schema where to store width. | 
| 
 | undefined | boolean = true If true, the field allows adding new options. | 
| 
 | undefined | ((options: AcceptFileOptions) => boolean | Promise A function that is called to check if the file is accepted. | 
| 
 | undefined | string | string[] Accepted mime types. | 
Audio upload field
The AudioUploadField component renders a file upload field for uploading audio files.
Props
| Prop | Description | 
|---|---|
| 
 | string The name of the column in Contember schema where to store file url. Required | 
| 
 | ReactNode The label for the field. Required | 
| 
 | ReactNode The description for the field. | 
| 
 | undefined | string The name of the column in Contember schema where to store file name. | 
| 
 | undefined | string The name of the column in Contember schema where to store file size. | 
| 
 | undefined | string The name of the column in Contember schema where to store file type. | 
| 
 | undefined | boolean = true If true, the field allows adding new options. | 
| 
 | undefined | ((options: AcceptFileOptions) => boolean | Promise A function that is called to check if the file is accepted. | 
| 
 | undefined | string | string[] Accepted mime types. | 
Image file repeater
The ImageFileRepeater component renders a file repeater for uploading image files.
- Component - simple
- Component - advanced
- API schema
<ImageFileRepeater
  field="images"
  urlField="image.url"
  label="Gallery"
  sortableBy="order"
/>
<ImageFileRepeater
  field="images"
  urlField="image.url"
  label="Gallery"
  description="image.description"
  heightField="image.height"
  widthField="image.width"
  fileSizeField="image.size"
  fileTypeField="image.type"
  sortableBy="order"
>
  <TextField field="image.description" label="Description" />
  <TextField field="image.alt" label="Alternative text" />
</ImageFileRepeater>
export class Gallery {
  images = def.oneHasMany(Image, "gallery");
}
export class Image {
  order = def.intColumn().notNull();
  url = def.stringColumn();
  description = def.stringColumn();
  height = def.stringColumn();
  width = def.stringColumn();
  size = def.stringColumn();
  type = def.stringColumn();
  gallery = def.manyHasOne(Gallery, "images");
}
Props
| Prop | Description | 
|---|---|
| 
 | string The name of the column in Contember schema where to store data. Required | 
| 
 | string The name of the column in Contember schema where to store file url. Required | 
| 
 | ReactNode The label for the field. Required | 
| 
 | undefined | string The name of the column in Contember schema that is used to sort the options. | 
| 
 | undefined | string The name of the column in Contember schema that is used to order the options. | 
| 
 | ReactNode The description for the field. | 
| 
 | undefined | string The name of the column in Contember schema where to store file name. | 
| 
 | undefined | string The name of the column in Contember schema where to store file size. | 
| 
 | undefined | string The name of the column in Contember schema where to store file type. | 
| 
 | undefined | string The name of the column in Contember schema where to store height. | 
| 
 | undefined | string The name of the column in Contember schema where to store width. | 
| 
 | undefined | boolean = true If true, the field allows adding new options. | 
| 
 | undefined | ((options: AcceptFileOptions) => boolean | Promise A function that is called to check if the file is accepted. | 
| 
 | undefined | string | string[] Accepted mime types. | 
Image upload field
The ImageUploadField component renders a file upload field for uploading image files.
Props
| Prop | Description | 
|---|---|
| 
 | string The name of the column in Contember schema where to store file url. Required | 
| 
 | ReactNode The label for the field. Required | 
| 
 | ReactNode The description for the field. | 
| 
 | undefined | string The name of the column in Contember schema where to store file name. | 
| 
 | undefined | string The name of the column in Contember schema where to store file size. | 
| 
 | undefined | string The name of the column in Contember schema where to store file type. | 
| 
 | undefined | string The name of the column in Contember schema where to store height. | 
| 
 | undefined | string The name of the column in Contember schema where to store width. | 
| 
 | undefined | boolean = true If true, the field allows adding new options. | 
| 
 | undefined | ((options: AcceptFileOptions) => boolean | Promise A function that is called to check if the file is accepted. | 
| 
 | undefined | string | string[] Accepted mime types. | 
| 
 | (options: RenderFilePreviewOptions Renders the file preview. | 
Video file repeater
The VideoFileRepeater component renders a file repeater for uploading video files.
- Component - simple
- Component - advanced
- API schema
<VideoFileRepeater
  field="videos"
  urlField="video.url"
  label="Video serie"
  sortableBy="order"
/>
<VideoFileRepeater
  field="videos"
  urlField="video.url"
  label="Video serie"
  description="video.description"
  fileSizeField="video.size"
  fileTypeField="video.type"
  sortableBy="order"
>
  <TextField field="video.description" label="Description" />
</VideoFileRepeater>
export class VideoSerie {
  videos = def.oneHasMany(Video, "serie");
}
export class Video {
  order = def.intColumn().notNull();
  url = def.stringColumn();
  description = def.stringColumn();
  size = def.stringColumn();
  type = def.stringColumn();
  serie = def.manyHasOne(VideoSerie, "videos");
}
Props
| Prop | Description | 
|---|---|
| 
 | string The name of the column in Contember schema where to store data. Required | 
| 
 | string The name of the column in Contember schema where to store file url. Required | 
| 
 | ReactNode The label for the field. Required | 
| 
 | undefined | string The name of the column in Contember schema that is used to sort the options. | 
| 
 | undefined | string The name of the column in Contember schema that is used to order the options. | 
| 
 | ReactNode The description for the field. | 
| 
 | undefined | string The name of the column in Contember schema where to store file name. | 
| 
 | undefined | string The name of the column in Contember schema where to store file size. | 
| 
 | undefined | string The name of the column in Contember schema where to store file type. | 
| 
 | undefined | boolean = true If true, the field allows adding new options. | 
| 
 | undefined | ((options: AcceptFileOptions) => boolean | Promise A function that is called to check if the file is accepted. | 
| 
 | undefined | string | string[] Accepted mime types. | 
Video upload field
The VideoUploadField component renders a file upload field for uploading video files.
Props
| Prop | Description | 
|---|---|
| 
 | string The name of the column in Contember schema where to store file url. Required | 
| 
 | ReactNode The label for the field. Required | 
| 
 | ReactNode The description for the field. | 
| 
 | undefined | string The name of the column in Contember schema where to store file name. | 
| 
 | undefined | string The name of the column in Contember schema where to store file size. | 
| 
 | undefined | string The name of the column in Contember schema where to store file type. | 
| 
 | undefined | string The name of the column in Contember schema where to store height. | 
| 
 | undefined | string The name of the column in Contember schema where to store width. | 
| 
 | undefined | boolean = true If true, the field allows adding new options. | 
| 
 | undefined | ((options: AcceptFileOptions) => boolean | Promise A function that is called to check if the file is accepted. | 
| 
 | undefined | string | string[] Accepted mime types. |