• Модуль: clouds
  • Путь к файлу: ~/bitrix/modules/clouds/classes/general/storage_service_s3.php
  • Класс: CCloudStorageService_S3
  • Вызов: CCloudStorageService_S3::FileExists
function FileExists($arBucket, $filePath)
{
	global $APPLICATION;

	if($arBucket["PREFIX"] != "")
	{
		if(mb_substr($filePath, 0, mb_strlen($arBucket["PREFIX"]) + 2) != "/".$arBucket["PREFIX"]."/")
			$filePath = "/".$arBucket["PREFIX"]."/".ltrim($filePath, "/");
	}
	$filePath = CCloudUtil::URLEncode($filePath, "UTF-8", true);

	$this->SetLocation($arBucket["LOCATION"]);
	$this->SendRequest(
		$arBucket["SETTINGS"],
		'HEAD',
		$arBucket["BUCKET"],
		$filePath
	);

	if($this->status == 200)
	{
		if (isset($this->headers["Content-Length"]) && $this->headers["Content-Length"] > 0)
			return $this->headers["Content-Length"];
		else
			return true;
	}
	elseif($this->status == 206)
	{
		$APPLICATION->ResetException();
		return true;
	}
	elseif($this->checkForTokenExpiration($this->status, $this->result))
	{
		$this->tokenHasExpired = true;
		return false;
	}
	else//if($this->status == 404)
	{
		$APPLICATION->ResetException();
		return false;
	}
}