• Модуль: clouds
  • Путь к файлу: ~/bitrix/modules/clouds/classes/general/storage_service_amazon.php
  • Класс: CCloudStorageService_AmazonS3
  • Вызов: CCloudStorageService_AmazonS3::GetFileSRC
function GetFileSRC($arBucket, $arFile, $encoded = true)
{
	$proto = CMain::IsHTTPS()? "https": "http";

	static $aps = null;
	if (!$aps)
		$aps = self::GetAPList();

	if($arBucket["CNAME"] != "")
	{
		$host = $arBucket["CNAME"];
		$pref = "";
	}
	elseif ($proto === "https" && strpos($arBucket["BUCKET"], ".") !== false)
	{
		if (isset($aps[$arBucket["LOCATION"]]))
			$host = $aps[$arBucket["LOCATION"]];
		else
			$host = $aps[""];

		$pref = $arBucket["BUCKET"];
	}
	else
	{
		if (isset($aps[$arBucket["LOCATION"]]))
			$host = $arBucket["BUCKET"].".".$aps[$arBucket["LOCATION"]];
		else
			$host = $aps[""];

		$pref = "";
	}

	if(is_array($arFile))
		$URI = ltrim($arFile["SUBDIR"]."/".$arFile["FILE_NAME"], "/");
	else
		$URI = ltrim($arFile, "/");

	if ($arBucket["PREFIX"] != "")
	{
		if(substr($URI, 0, strlen($arBucket["PREFIX"])+1) !== $arBucket["PREFIX"]."/")
			$URI = $arBucket["PREFIX"]."/".$URI;
	}

	if ($pref !== "")
	{
		$URI = $pref."/".$URI;
	}

	if ($encoded)
	{
		return $proto."://$host/".CCloudUtil::URLEncode($URI, "UTF-8", true);
	}
	else
	{
		return $proto."://$host/".$URI;
	}
}