toloka.client.project.template_builder.fields.MediaFileFieldV1
| Source code
MediaFileFieldV1( self, data: Optional[BaseComponent] = None, accept: Optional[Union[BaseComponent, Accept]] = None, *, multiple: Optional[Union[BaseComponent, bool]] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, version: Optional[str] = '1.0.0')
Adds buttons for different types of uploads: uploading photos or videos, selecting files from the file manager or choosing from the gallery.
In the accept property, select which buttons you need.
By default, only one file can be uploaded, but you can allow multiple files in the multiple property.
This component is convenient when using mobile devices. To upload files from a computer, it's better to use field.file for a more flexible configuration of the file types.
Parameters | Type | Description |
---|---|---|
data | Optional[BaseComponent] | Data with values that will be processed or changed. |
accept | Optional[Union[BaseComponent, Accept]] | Adds different buttons for four types of uploads. Pass the |
multiple | Optional[Union[BaseComponent, bool]] | Determines whether multiple files can be uploaded: |
hint | Optional[Any] | Hint text. |
label | Optional[Any] | Label above the component. |
validation | Optional[BaseComponent] | Validation based on condition. |
Examples:
How to allow Tolokers to upload images and make photos.
image_loader = tb.fields.MediaFileFieldV1( label='Upload a photo', data=tb.data.OutputData(path='image'), validation=tb.conditions.RequiredConditionV1(), accept=tb.fields.MediaFileFieldV1.Accept(photo=True, gallery=True), multiple=False,)