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

	@set_time_limit(0);
	$http = new HttpClient(array(
		'socketTimeout' => 10,
		'streamTimeout' => 30,
		'version' => HttpClient::HTTP_1_1,
	));

	$http->setHeader('X-co-auth-token', $this->getAccessToken());

	if($startRange !== null && $chunkSize !== null)
	{
		$endRange = $startRange + $chunkSize - 1;
		$http->setHeader('Range', "bytes={$startRange}-{$endRange}");
	}

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

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

	return $fileData;
}