• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/rest/service/storage.php
  • Класс: Bitrix\Disk\Rest\Service\Storage
  • Вызов: Storage::uploadFile
protected function uploadFile($id, $fileContent, array $data, array $rights = array(), $generateUniqueName = false)
{
	if(!$this->checkRequiredInputParams($data, array('NAME')))
	{
		return null;
	}

	$storage = $this->getStorageById($id);
	$securityContext = $storage->getCurrentUserSecurityContext();
	if(!$storage->getRootObject()->canAdd($securityContext))
	{
		throw new AccessException;
	}
	if ($rights && !$storage->getRootObject()->canChangeRights($securityContext))
	{
		throw new AccessException;
	}
	$fileData = \CRestUtil::saveFile($fileContent);
	if(!$fileData)
	{
		throw new RestException('Could not save file.');
	}
	$file = $storage->uploadFile($fileData, array(
		'NAME' => $data['NAME'],
		'CREATED_BY' => $this->userId
	), $rights, $generateUniqueName);
	if(!$file)
	{
		$this->errorCollection->add($storage->getErrors());
		return null;
	}

	return $file;
}