imageOptimizerService->optimize($file); return $this->storageService->storeFileOntoDisk($optimized, $this->s3Disk->disk); } public function deleteIfReplaced( ?StorageFilePath $oldPath, ?StorageFilePath $newPath, ): void { if ($oldPath === null || $newPath === null || $oldPath->value === $newPath->value) { return; } if ($this->storageService->fileExistsOnDisk($oldPath, $this->s3Disk->disk)) { $this->storageService->removeFromDisk($oldPath, $this->s3Disk->disk); } } }