public function uploadToLibrary(User $user, array $fileArray)
    {

        $nameFile = new FileImpl(isset($fileArray['name'])?$fileArray['name']:$fileArray['tmp_name']);
        $file = new FileImpl($fileArray['tmp_name']);
        $folder = new FolderImpl($this->filesDir->getAbsolutePath()."/".$user->getUniqueId());
        $ext = $nameFile->getExtension() == ""?"":".".$nameFile->getExtension();
        $name = str_replace(".", "", uniqid("",true)).$ext;
        if(!$this->filesDir->exists()){
            $this->filesDir->create();
        }
        if(!$folder->exists()){
            $folder->create();
        }
        $f = new FileImpl($folder->getAbsolutePath().'/'.$name);
        move_uploaded_file($file->getAbsoluteFilePath(),$f->getAbsoluteFilePath());
        return $f;
    }