Newscoop\Storage\StorageService::moveFile PHP 메소드

moveFile() 개인적인 메소드

Move file in given path to storage starting at root
private moveFile ( string $path, string $root ) : string
$path string
$root string
리턴 string
    private function moveFile($path, $root)
    {
        $hash = sha1($this->adapter->fetchItem($path));
        $name = sprintf('%s/%s/%s.%s', substr($hash, 0, 1), substr($hash, 1, 2), $hash, pathinfo($path, PATHINFO_EXTENSION));
        $dest = trim($root, '/') . '/' . $name;
        if (is_string($this->adapter->getClient())) {
            $dir = $this->adapter->getClient() . '/' . dirname($dest);
            if (!is_dir($dir)) {
                mkdir($dir, 0755, true);
            }
        }
        $this->adapter->moveItem($path, $dest);
        return $name;
    }