StorageRepository & Move File

StorageRepository

$storageRepository = $this->objectManager->get('TYPO3\CMS\Core\Resource\StorageRepository');
// storage 1 == fileadmin
$storage = $storageRepository->findByUid('1');
$subFolder = $storage->createFolder('subFolder');
$tempFile = 'typo3temp/filePathTemp.jpg';
$moveFile = $storage->addFile($tempFile,$subFolder,'newFile.jpg');

Move File

$fileReference = $this->objectManager->get('TYPO3\CMS\Extbase\Domain\Model\FileReference');
$fileReference->setFile($moveFile);

Add File To News

 $news->addFalMedia($fileReference);