Adding image to object

Hello,

i’m trying to create a product and a variant programmatically in my ProductController, actually everything work but when i’m trying to add an image to a product or variant i have some problems.

As you can see here :
// Product image factory

/** @var ProductImageFactory $productImageFactory */
$productImageFactory = $this->get('sylius.factory.product_image');

$imagePath = '/Users/siege/Downloads/iphone11.jpeg';

$uploadedImage = new UploadedFile($imagePath, basename($imagePath));
$filePath = $uploadedImage->getRealPath();

/** @var ImageInterface $productImage */
$productImage = $productImageFactory->createNew();
$productImage->setFile($uploadedImage);

$this->imageUploader->upload($productImage);
$productImage->setPath($filePath);
$productImage->setOwner($variant);
$productImage->setType('main');

# Adding image to variant
$variant->addImage($productImage);

When i use $this->imageUploader->upload($productImage); i get this error :
Notice: Undefined property: App\Controller\Product\ProductController::$imageUploader

Anyone have a proper solution to add an image to a product or variant please ?