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

	$arFiles = $this->ListFiles($arBucket, '/', false, 1);
	if(is_array($arFiles))
		return true;

	// The bucket already exists and user has specified wrong location
	if (
		$this->status == 301
		&& $arBucket["LOCATION"] != ""
		&& $this->GetLastRequestHeader('x-amz-bucket-region') != ''
		&& $this->GetLastRequestHeader('x-amz-bucket-region') != $arBucket["LOCATION"]
	)
	{
		return false;
	}

	if($arBucket["LOCATION"] != "")
		$content =
			''.
			''.$arBucket["LOCATION"].''.
			'';
	else
		$content = '';

	$this->SetLocation($arBucket["LOCATION"]);
	$response = $this->SendRequest(
		$arBucket["SETTINGS"],
		'PUT',
		$arBucket["BUCKET"],
		'/',
		'',
		$content
	);

	if($this->status == 409/*Already exists*/)
	{
		$APPLICATION->ResetException();
		return true;
	}
	elseif (is_array($response))
	{
		return true;
	}
	else
	{
		if (defined("BX_CLOUDS_ERROR_DEBUG"))
		{
			AddMessage2Log($this);
		}
		return false;
	}
}