skeeks\cms\components\storage\ClusterLocal::upload PHP Method

upload() public method

Добавление файла в кластер
public upload ( skeeks\sx\File $tmpFile ) : string
$tmpFile skeeks\sx\File
return string
    public function upload(File $tmpFile)
    {
        $clusterFileName = $this->_generateClusterFileName($tmpFile);
        $dir = $this->rootBasePath;
        $localPath = $this->getClusterDir($clusterFileName);
        $clusterFileSrc = $clusterFileName;
        if ($localPath) {
            $clusterFileSrc = $localPath . DIRECTORY_SEPARATOR . $clusterFileSrc;
        }
        try {
            $dir = new Dir($dir . DIRECTORY_SEPARATOR . $localPath);
            $resultFile = $dir->newFile($clusterFileName);
            $tmpFile->move($resultFile);
        } catch (Exception $e) {
            throw new Exception($e->getMessage());
        }
        return $clusterFileSrc;
    }