public function test_rename() { Curl::mockUpload($this); Uploader::rename("foobar", "foobar2", array("overwrite" => TRUE)); assertUrl($this, "/image/rename"); assertParam($this, "overwrite", 1); assertParam($this, "from_public_id", "foobar"); assertParam($this, "to_public_id", "foobar2"); }
public function move($from, $to) { try { $response = Uploader::rename($from, $to); return $response; } catch (Cloudinary\Error $e) { return ['error' => 'M0001']; } }
public function rename($path, $newpath) { return Uploader::rename($path, $newpath); }
/** * Rename a file. * Paths without extensions. * * @param string $path * @param string $newpath * * @return bool */ public function rename($path, $newpath) { $pathinfo = pathinfo($path); if ($pathinfo['dirname'] != '.') { $path_remote = $pathinfo['dirname'] . '/' . $pathinfo['filename']; } else { $path_remote = $pathinfo['filename']; } $newpathinfo = pathinfo($newpath); if ($newpathinfo['dirname'] != '.') { $newpath_remote = $newpathinfo['dirname'] . '/' . $newpathinfo['filename']; } else { $newpath_remote = $newpathinfo['filename']; } $result = Uploader::rename($path_remote, $newpath_remote); return $result['public_id'] == $newpathinfo['filename']; }