Uploads
Any upload field​
The AnyUploadField
component renders a file upload field for uploading any file.
- Component - simple
- Component - advanced
- API schema
<AnyUploadField field="file" urlField="file.url" />
<AnyUploadField
field="file"
urlField="file.url"
label="File"
fileNameField="file.name"
fileSizeField="file.size"
fileTypeField="file.type"
widthField="file.width"
heightField="file.height"
acceptMimeTypes={["image/jpeg", "image/png"]}
>
<TextField field="file.description" label="Description" />
</AnyUploadField>
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 upload field​
The AudioUploadField
component renders a file upload field for uploading audio files.
- Component - simple
- Component - advanced
- API schema
<AudioUploadField urlField="" label="" />
<AudioUploadField urlField="" label="" />
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 upload field​
The ImageUploadField
component renders a file upload field for uploading image files.
<ImageUploadField urlField="" label="" />
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 upload field​
The VideoUploadField
component renders a file upload field for uploading video files.
<VideoUploadField urlField="" label="" />
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. |
Any file repeater​
The AnyFileRepeater
component renders a repeater field for uploading any file.
<AnyFileRepeater field="" label="" urlField="" />
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. |
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. |
Video file repeater​
The VideoFileRepeater
component renders a file repeater for uploading video files.
- Component - simple
- Component - advanced
- API schema
<ImageFileRepeater
field="videos"
urlField="video.url"
label="Video serie"
sortableBy="order"
/>
<ImageFileRepeater
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" />
</ImageFileRepeater>
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. |