protected function saveFile($path, $name)
    {
        $filename = $this->getUniqueFilename($name);

        /** @var \oat\oatbox\filesystem\Directory $dir */
        $dir = $this->getServiceManager()->get(FileSystemService::SERVICE_ID)
            ->getDirectory(Queue::FILE_SYSTEM_ID);
        /** @var \oat\oatbox\filesystem\FileSystem $filesystem */
        $filesystem = $dir->getFileSystem();

        $stream = fopen($path, 'r+');
        $filesystem->writeStream($filename, $stream);
        fclose($stream);

        $file = $dir->getFile($filename);
        return $this->getFileReferenceSerializer()->serialize($file);
    }