def create(self, request, *args, **kwargs):
        # Check permission to check if the uploader has to be changed.
        uploader_id = self.request.data.get('uploader_id')
        if (uploader_id and
                not request.user.has_perm('mediafiles.can_manage') and
                str(self.request.user.pk) != str(uploader_id)):
            self.permission_denied(request)
        if not self.request.data.get('mediafile'):
            raise ValidationError({'detail': 'You forgot to provide a file.'})
        return super().create(request, *args, **kwargs)
Customized view endpoint to upload a new file.
dataset/ETHPy150Open OpenSlides/OpenSlides/openslides/mediafiles/views.py/MediafileViewSet.create