Qiniu\Storage\BucketManager::move PHP Method

move() public method

将资源从一个空间到另一个空间
public move ( $from_bucket, $from_key, $to_bucket, $to_key, $force = false ) : mixed
$from_bucket 待操作资源所在空间
$from_key 待操作资源文件名
$to_bucket 目标资源空间名
$to_key 目标资源文件名
return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error
    public function move($from_bucket, $from_key, $to_bucket, $to_key, $force = false)
    {
        $from = \Qiniu\entry($from_bucket, $from_key);
        $to = \Qiniu\entry($to_bucket, $to_key);
        $path = '/move/' . $from . '/' . $to;
        if ($force) {
            $path .= '/force/true';
        }
        list(, $error) = $this->rsPost($path);
        return $error;
    }

Usage Example

Example #1
0
 /**
  * 移动文件
  *
  * @param $fromBucket
  * @param $fromFile
  * @param $toBucket
  * @param $toFile
  * @return \Qiniu\Storage\成功返回NULL|string
  */
 public function move($fromBucket, $fromFile, $toBucket, $toFile)
 {
     $bucketManager = new BucketManager($this->auth);
     $error = $bucketManager->move($fromBucket, $fromFile, $toBucket, $toFile);
     if ($error !== null) {
         return $error;
     } else {
         return "Success";
     }
 }
All Usage Examples Of Qiniu\Storage\BucketManager::move