• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/document/myofficehandler.php
  • Класс: BitrixDiskDocumentMyOfficeHandler
  • Вызов: MyOfficeHandler::getFileMetadata
public function getFileMetadata(FileData $fileData)
{
	if(!$this->checkRequiredInputParams($fileData->toArray(), array(
		'id',
	)))
	{
		return null;
	}

	$http = new HttpClient(array(
		'socketTimeout' => 10,
		'streamTimeout' => 30,
		'version' => HttpClient::HTTP_1_1,
	));
	$http->setHeader('Content-Type', 'application/json; charset=UTF-8');
	$http->setHeader('X-co-auth-token', $this->getAccessToken());

	if($http->get($this->getApiUrlRoot() . "/files/{$fileData->getId()}") === false)
	{
		$errorString = implode('; ', array_keys($http->getError()));
		$this->errorCollection->add(array(
			new Error($errorString, self::ERROR_HTTP_GET_METADATA)
		));
		return null;
	}

	if(!$this->checkHttpResponse($http))
	{
		return null;
	}

	$metaData = Json::decode($http->getResult());
	if($metaData === null)
	{
		$this->errorCollection->add(array(
			new Error('Could not decode response as json', self::ERROR_BAD_JSON)
		));
		return null;
	}

	if(!isset($metaData['file']))
	{
		$this->errorCollection->add(array(
			new Error('Could not get meta-data', self::ERROR_HTTP_GET_METADATA)
		));
		return null;
	}

	return $this->normalizeMetadata($metaData);
}