Newscoop\Storage\StorageService::moveFile PHP Method

moveFile() private method

Move file in given path to storage starting at root
private moveFile ( string $path, string $root ) : string
$path string
$root string
return 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;
    }