public static function OnMakeFileArray($arSourceFile, &$arDestination) { if (!is_array($arSourceFile)) { $file = $arSourceFile; if (substr($file, 0, strlen($_SERVER["DOCUMENT_ROOT"])) == $_SERVER["DOCUMENT_ROOT"]) { $file = ltrim(substr($file, strlen($_SERVER["DOCUMENT_ROOT"])), "/"); } if (!preg_match("/^http:\\/\\//", $file)) { return false; } $bucket = CCloudStorage::FindBucketByFile($file); if (!is_object($bucket)) { return false; } $filePath = substr($file, strlen($bucket->GetFileSRC("/")) - 1); $filePath = urldecode($filePath); $target = CFile::GetTempName('', bx_basename($filePath)); $target = preg_replace("#[\\\\\\/]+#", "/", $target); if ($bucket->DownloadToFile($filePath, $target)) { $arDestination = $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"] = strlen($arSourceFile['ORIGINAL_NAME']) > 0 ? $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; } }
function MakeFileArray($file, $fields = array()) { if (is_array($file)) { if (array_key_exists($this->mess["IBLOCK_XML2_BX_URL"], $file) && strlen($file[$this->mess["IBLOCK_XML2_BX_URL"]]) > 0) { if (CModule::IncludeModule('clouds')) { $bucket = CCloudStorage::FindBucketByFile($file[$this->mess["IBLOCK_XML2_BX_URL"]]); if (is_object($bucket) && $bucket->READ_ONLY === "Y") { return array("name" => $file[$this->mess["IBLOCK_XML2_BX_ORIGINAL_NAME"]], "description" => $file[$this->mess["IBLOCK_XML2_DESCRIPTION"]], "tmp_name" => $file[$this->mess["IBLOCK_XML2_BX_URL"]], "file_size" => $file[$this->mess["IBLOCK_XML2_BX_FILE_SIZE"]], "width" => $file[$this->mess["IBLOCK_XML2_BX_FILE_WIDTH"]], "height" => $file[$this->mess["IBLOCK_XML2_BX_FILE_HEIGHT"]], "type" => $file[$this->mess["IBLOCK_XML2_BX_FILE_CONTENT_TYPE"]], "content" => "", "bucket" => $bucket); } } return CFile::MakeFileArray($this->URLEncode($file[$this->mess["IBLOCK_XML2_BX_URL"]])); //Download from the cloud } } else { if (strlen($file) > 0) { $external_id = md5($file); if (is_file($this->files_dir . $file)) { return CFile::MakeFileArray($this->files_dir . $file, false, false, $external_id); } $fileId = $this->CheckFileByName($external_id, $fields); if ($fileId > 0) { return CFile::MakeFileArray($fileId); } } } return array("tmp_name" => "", "del" => "Y"); }
function MakeFileArray($file) { if( (!is_array($file)) && (strlen($file) > 0) && is_file($this->files_dir.$file) ) { return CFile::MakeFileArray($this->files_dir.$file); } elseif(is_array($file) && array_key_exists(GetMessage("IBLOCK_XML2_BX_URL"), $file)) { if(CModule::IncludeModule('clouds')) { $bucket = CCloudStorage::FindBucketByFile($file[GetMessage("IBLOCK_XML2_BX_URL")]); if(is_object($bucket) && $bucket->READ_ONLY === "Y") { return array( "name" => $file[GetMessage("IBLOCK_XML2_BX_ORIGINAL_NAME")], "description" => $file[GetMessage("IBLOCK_XML2_DESCRIPTION")], "tmp_name" => $file[GetMessage("IBLOCK_XML2_BX_URL")], "file_size" => $file[GetMessage("IBLOCK_XML2_BX_FILE_SIZE")], "width" => $file[GetMessage("IBLOCK_XML2_BX_FILE_WIDTH")], "height" => $file[GetMessage("IBLOCK_XML2_BX_FILE_HEIGHT")], "type" => $file[GetMessage("IBLOCK_XML2_BX_FILE_CONTENT_TYPE")], "content" => "", //Fake field in order to avoid warning "bucket" => $bucket, ); } } return CFile::MakeFileArray($this->URLEncode($file[GetMessage("IBLOCK_XML2_BX_URL")])); //Download from the cloud } else return array("tmp_name"=>"", "del"=>"Y"); }