• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/controller/onlyoffice.php
  • Класс: BitrixDiskControllerOnlyOffice
  • Вызов: OnlyOffice::downloadAction
public function downloadAction(ModelsDocumentSession $documentSession): ?ResponseBFile
{
	$this->enableExtendedErrorInfo();

	$bfileId = null;
	$fileName = null;
	if ($documentSession->isVersion() && $documentSession->getVersion())
	{
		$bfileId = $documentSession->getVersion()->getFileId();
		$fileName = $documentSession->getVersion()->getName();
	}
	elseif (!$documentSession->isVersion() && $documentSession->getFile())
	{
		$bfileId = $documentSession->getFile()->getFileId();
		$fileName = $documentSession->getFile()->getName();
	}

	if (!$bfileId || !$fileName)
	{
		$this->addError(new Error('Could find file or version for this document session'));

		return null;
	}

	return ResponseBFile::createByFileId($bfileId, $fileName);
}