How to append an image to a product

I import products essentially by calling productrepository.upsert(['name'=>...]);
What is the established best practice to append product pictures, so that they get saved to disk and all the media_* tables get populated?

Thanks!

That is awesome, thank you so much.

My rather ugly approach was to first create the entity via the product repository with

 [
        'id' => <productid>,
        'productNumber' =>...,
        'media' => [
            [
                'id' => ...,
                'position' => 0,
                'media' => [
                        'id' => ...,
                        'fileName' => ...,
                        'fileSize' => ...,
                        'mediaFolderId' => $this->getDefaultProductMediaFolderId(),
                ]
            ]
        ]
    ]

then load that entity, work out the directory the picture is expected to be in, and save the image there.
It kinda worked, but screwed the thumbnail generation.