• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/integration/disk/rest/attachment.php
  • Класс: BitrixTasksIntegrationDiskRestAttachment
  • Вызов: Attachment::getById
static function getById($id, $parameters = array())
{
	if(!is_array($parameters))
	{
		$parameters = array();
	}

	$result = array(
		'ATTACHMENT_ID' => $id
	);

	if(!Loader::includeModule('disk'))
	{
		return $result;
	}

	$id = intval($id);
	if(!$id)
	{
		return $result;
	}
	$attachedObject = AttachedObject::getById($id, array('OBJECT'));
	if(!$attachedObject || !$attachedObject->getFile())
	{
		return $result;
	}

	$result['NAME'] = $attachedObject->getFile()->getName();
	$result['SIZE'] = $attachedObject->getFile()->getSize();
	$result['FILE_ID'] = $attachedObject->getObjectId();

	$controllerParams = array('attachedId' => $id);
	if(isset($parameters['SERVER']) && ($parameters['SERVER'] instanceof CRestServer))
	{
		$controllerParams['auth'] = $parameters['SERVER']->getAuth();
	}

	$result['DOWNLOAD_URL'] = Driver::getInstance()->getUrlManager()->getUrlUfController('download', $controllerParams);
	$result['VIEW_URL'] = Driver::getInstance()->getUrlManager()->getUrlUfController('show', $controllerParams);

	return $result;
}