示例#1
0
 /**
  *	Восстановление файла или папки из Корзины
  *	В корзине файлы с одинаковыми именами в действительности именют постфикс к имени в виде unixtime
  *
  *	@param	mixed	$name	елси boolean это заменяет overwrite
  *	@param	boolean	$overwrite
  *	@return	mixed
  */
 public function restore($name = null, $overwrite = false)
 {
     if (is_bool($name)) {
         $overwrite = $name;
         $name = null;
     }
     if (!empty($name) && !is_string($name)) {
         throw new \InvalidArgumentException('Новое имя для восстанавливаемого ресурса должо быть строкой');
     }
     $this->request->put($this->parent_disk->getRequestUrl('trash/resources/restore', array('path' => $this->getPath(), 'name' => (string) $name, 'overwrite' => (bool) $overwrite)), '');
     if (!empty($response['operation'])) {
         return $response['operation'];
     }
     return $this;
 }
示例#2
0
 /**
  *	Сохранение публичного файла в «Загрузки» или отдельный файл из публичной папки
  *
  *	@param	string	$name	Имя, под которым файл следует сохранить в папку «Загрузки»
  *	@param	string	$path	Путь внутри публичной папки.
  *	@return	mixed	
  */
 public function save($name = null, $path = null)
 {
     $params = array();
     if (is_string($path)) {
         $params['path'] = $path;
     }
     if (is_string($name)) {
         $params['name'] = $name;
     } else {
         if ($name instanceof Resource) {
             $params['name'] = substr(strrchr($name->getPath(), '/'), 1);
         }
     }
     $this->request->post($this->parent_disk->getRequestUrl('public/resources/save-to-disk', array('public_key' => $this->getPublicKey()) + $params));
     if (!empty($response['operation'])) {
         return $response['operation'];
     }
     return $this->request->http_status_code == 201;
 }