예제 #1
0
 /**
  *	Перемещение файла или папки
  *
  *	@param	string|Resource
  */
 public function move($path_to, $overwrite = false)
 {
     if ($path_to instanceof Resource) {
         $path_to = $path_to->getPath();
     } else {
         if ($path_to instanceof ResourcePublish) {
             return false;
         }
     }
     $response = $this->request->post($this->parent_disk->getRequestUrl('resources/move', array('from' => $this->resource_path, 'path' => $path_to, 'overwrite' => (bool) $overwrite)));
     $this->resource_path = $path_to;
     if (!empty($response['operation'])) {
         return $response['operation'];
     }
     return $this->request->http_status_code == 201;
 }
예제 #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;
 }