MediaFileFieldV1

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 Description

ParametersTypeDescription
dataOptional[BaseComponent]

Data with values that will be processed or changed.

acceptOptional[Union[BaseComponent, Accept]]

Adds different buttons for four types of uploads. Pass the True value for the ones that you need. For example, if you need a button for uploading files from the gallery, add the gallery=True.

multipleOptional[Union[BaseComponent, bool]]

Determines whether multiple files can be uploaded:

hintOptional[Any]

Hint text.

labelOptional[Any]

Label above the component.

validationOptional[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,
)
Toloka-Kit
OverviewGetting OAuth tokenQuick start
Recipes
Reference
toloka.client
toloka.async_client
toloka.autoquality [autoquality]
toloka.metrics
toloka.streaming