• Модуль: clouds
  • Путь к файлу: ~/bitrix/modules/clouds/classes/general/storage_service.php
  • Класс: CCloudStorageService
  • Вызов: CCloudStorageService::FileRename
public function FileRename($arBucket, $sourcePath, $targetPath, $overwrite = true)
{
	if ($this->FileExists($arBucket, $sourcePath))
	{
		$contentType = $this->headers["Content-Type"];
	}
	else
	{
		return false;
	}

	if ($this->FileExists($arBucket, $targetPath))
	{
		if (!$overwrite)
		{
			return false;
		}

		if (!$this->DeleteFile($arBucket, $targetPath))
		{
			return false;
		}
	}

	$arFile = array(
		"SUBDIR" => '',
		"FILE_NAME" => ltrim($sourcePath, "/"),
		"CONTENT_TYPE" => $contentType,
	);

	if (!$this->FileCopy($arBucket, $arFile, $targetPath))
	{
		return false;
	}

	if (!$this->DeleteFile($arBucket, $sourcePath))
	{
		return false;
	}

	return true;
}