public static function OnFileCopy(&$arFile, $newPath = "") { if ($arFile["HANDLER_ID"] <= 0) { return false; } $bucket = new CCloudStorageBucket($arFile["HANDLER_ID"]); if (!$bucket->Init()) { return false; } if ($bucket->READ_ONLY == "Y") { return false; } $filePath = ""; $newName = ""; if (strlen($newPath)) { $filePath = "/" . trim(str_replace("//", "/", $newPath), "/"); } else { $strFileExt = strrchr($arFile["FILE_NAME"], "."); while (true) { $newName = md5(uniqid(mt_rand(), true)) . $strFileExt; $filePath = "/" . $arFile["SUBDIR"] . "/" . $newName; if (!$bucket->FileExists($filePath)) { break; } } } $result = $bucket->FileCopy($arFile, $filePath); if ($result) { $bucket->IncFileCounter($arFile["FILE_SIZE"]); if (strlen($newPath)) { $arFile["FILE_NAME"] = bx_basename($filePath); $arFile["SUBDIR"] = substr($filePath, 1, -(strlen(bx_basename($filePath)) + 1)); } else { $arFile["FILE_NAME"] = $newName; } } return $result; }
fseek($fp, $obUpload->getPos()); $part = fread($fp, $obUpload->getPartSize()); fclose($fp); while($obUpload->hasRetries()) if($res = $obUpload->Next($part)) break; if ($res) { $pos = $obUpload->getPos(); if ($pos >= $file_size) // file ended { if($obUpload->Finish()) { $NS['pos'] += $file_size; $oBucket = new CCloudStorageBucket($NS['BUCKET_ID']); $oBucket->IncFileCounter($file_size); if (file_exists($arc_name = CTar::getNextName($NS['arc_name']))) $NS['arc_name'] = $arc_name; else { $name = preg_replace('#\.[0-9]+$#','',$NS['arc_name']); while(file_exists($name)) { $size = filesize($name); if (unlink($name) && IntOption("disk_space") > 0) CDiskQuota::updateDiskQuota("file",$size , "del"); $name = CTar::getNextName($name); } $NS["step"]++;
?> , <?php echo min($fileSize - 1, $bytes + $PHPchunkSize - 1); ?> ); </script><?php } else { $ar = CFile::MakeFileArray($absPath); if (!is_array($ar) || !isset($ar["tmp_name"])) { $strError = GetMessage("CLO_STORAGE_FILE_UNKNOWN_ERROR", array("#CODE#" => "e11")); } else { $res = $obBucket->SaveFile($filePath, $ar); if ($res) { $bytes = $fileSize; $moveResult = CCloudStorage::FILE_MOVED; $obBucket->IncFileCounter($fileSize); } else { $strError = GetMessage("CLO_STORAGE_FILE_UNKNOWN_ERROR", array("#CODE#" => "e12")); } @unlink($absPath); } } } else { $obUpload = new CCloudStorageUpload($filePath); if (!$obUpload->isStarted()) { if ($obUpload->Start($obBucket->ID, $fileSize, $_REQUEST["file_type"])) { $moveResult = CCloudStorage::FILE_PARTLY_UPLOADED; ?> <script> readFileChunk(0, <?php echo $PHPchunkSize - 1;