• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
  • Класс: CIMRestService
  • Вызов: CIMRestService::diskFileSave
static function diskFileSave($arParams, $n, CRestServer $server)
{
	$arParams = array_change_key_case($arParams, CASE_UPPER);

	$fileId = isset($arParams['FILE_ID'])? intval($arParams['FILE_ID']): intval($arParams['DISK_ID']);
	if ($fileId <= 0)
	{
		throw new BitrixRestRestException("File ID can't be empty", "FILE_ID_EMPTY", CRestServer::STATUS_WRONG_REQUEST);
	}

	$result = CIMDisk::SaveToLocalDisk($fileId);
	if (!$result)
	{
		throw new BitrixRestRestException("File ID can't be saved", "FILE_SAVE_ERROR", CRestServer::STATUS_WRONG_REQUEST);
	}

	return [
		'folder' => [
			'id' => (int)$result['FOLDER']->getId(),
			'name' => $result['FOLDER']->getName()
		],
		'file' => [
			'id' => (int)$result['FILE']->getId(),
			'name' => $result['FILE']->getName()
		],
	];
}