/** * Update the contents of a specific object * @param string $objectPath * @param string $content * @return boolean */ public function updateObject($objectPath, $content) { # if($this->checkExt($objectPath) !== true){ # return false; # } # if(mb_strpos($objectPath, '/', null, $this->xpdo->getOption('charset', 'utf-8')) !== 0){ # $objectPath = '/'.$objectPath; # } $path = $this->getPath($objectPath); // Check file exists $response = null; try { $response = $this->getClient()->getMetadata($path); } catch (Exception $e) { $error = $this->lexicon('getContent', array('path' => $path, 'message' => $e->getMessage()), 'error'); $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, $error); $this->addError('file', $error); return false; } if (!$response) { $error = $this->lexicon('objectNotExists', array('path' => $path), 'error'); $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, $error); $this->addError('file', $error); return false; } $response = null; try { $response = $this->getClient()->uploadFileFromString($path, dbx\WriteMode::update(null), $content); } catch (Exception $e) { $error = $this->lexicon('updateObject', array('path' => $path, 'message' => $e->getMessage()), 'error'); $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, $error); $this->addError('file', $error); return false; } // Remove cache $fileName = $this->xpdo->getOption(xPDO::OPT_CACHE_PATH) . $this->getCacheFileName($path, 'content'); if (file_exists($fileName)) { @unlink($fileName); } $key = $this->getCacheFileName($path, 'meta'); $this->xpdo->cacheManager->delete($key); // TODO: Need to be implemented return true; }