- Модуль: clouds
- Путь к файлу: ~/bitrix/modules/clouds/classes/general/storage.php
- Класс: CCloudStorage
- Вызов: CCloudStorage::OnMakeFileArray
static function OnMakeFileArray($arSourceFile, &$arDestination)
{
if (!is_array($arSourceFile))
{
$file = $arSourceFile;
if (mb_substr($file, 0, mb_strlen($_SERVER["DOCUMENT_ROOT"])) == $_SERVER["DOCUMENT_ROOT"])
$file = ltrim(mb_substr($file, mb_strlen($_SERVER["DOCUMENT_ROOT"])), "/");
if (!preg_match("/^https?:\/\//", $file))
return false;
$bucket = CCloudStorage::FindBucketByFile($file);
if (!is_object($bucket))
return false;
$filePath = mb_substr($file, mb_strlen($bucket->GetFileSRC("/")) - 1);
$filePath = BitrixMainTextEncoding::convertEncoding(rawurldecode($filePath), "UTF-8", LANG_CHARSET);
$io = CBXVirtualIo::GetInstance();
$target = CFile::GetTempName('', bx_basename($filePath));
$target = preg_replace("#[\\\/]+#", "/", $target);
if ($bucket->DownloadToFile($filePath, $target))
{
$arDestination = $io->GetPhysicalName($target);
}
return true;
}
else
{
if ($arSourceFile["HANDLER_ID"] <= 0)
return false;
$bucket = new CCloudStorageBucket($arSourceFile["HANDLER_ID"]);
if (!$bucket->Init())
return false;
$target = CFile::GetTempName('', $arSourceFile["FILE_NAME"]);
$target = preg_replace("#[\\\/]+#", "/", $target);
if ($bucket->DownloadToFile($arSourceFile, $target))
{
$arDestination["name"] = ($arSourceFile['ORIGINAL_NAME'] <> ''? $arSourceFile['ORIGINAL_NAME']: $arSourceFile['FILE_NAME']);
$arDestination["size"] = $arSourceFile['FILE_SIZE'];
$arDestination["type"] = $arSourceFile['CONTENT_TYPE'];
$arDestination["description"] = $arSourceFile['DESCRIPTION'];
$arDestination["tmp_name"] = $target;
}
return true;
}
}