public function testDeleteMoveCopy() { $key2 = 'testOp2' . getTid(); $key3 = 'testOp3' . getTid(); Qiniu_RS_Delete($this->client, $this->bucket, $key2); Qiniu_RS_Delete($this->client, $this->bucket, $key3); $err = Qiniu_RS_Copy($this->client, $this->bucket, $this->key, $this->bucket, $key2); $this->assertNull($err); $err = Qiniu_RS_Move($this->client, $this->bucket, $key2, $this->bucket, $key3); $this->assertNull($err); $err = Qiniu_RS_Delete($this->client, $this->bucket, $key3); $this->assertNull($err); $err = Qiniu_RS_Delete($this->client, $this->bucket, $key2); $this->assertNotNull($err, "delete key2 false"); }
} else { var_dump($ret); } # @endgist //------------------------------------rs----------------------------------------- # @gist stat list($ret, $err) = Qiniu_RS_Stat($client, $bucket, $key1); echo "\n\n====> Qiniu_RS_Stat result: \n"; if ($err !== null) { var_dump($err); } else { var_dump($ret); } # @endgist # @gist copy $err = Qiniu_RS_Copy($client, $bucket, $key1, $bucket, $key2); echo "\n\n====> Qiniu_RS_Copy result: \n"; if ($err !== null) { var_dump($err); } else { echo "Success! \n"; } # @endgist # @gist delete $err = Qiniu_RS_Delete($client, $bucket, $key1); echo "\n\n====> Qiniu_RS_Delete result: \n"; if ($err !== null) { var_dump($err); } else { echo "Success! \n"; }
/** * Copy a file * * @param $path * @param $newpath * @return bool */ public function copy($path, $newpath) { $err = Qiniu_RS_Copy($this->getClient(), $this->bucket, $path, $this->bucket, $newpath); return $err === null; }
public function copy($oldKey, $newKey, $newBucket = null) { if ($newBucket === null) { $newBucket = $this->bucket; } $err = Qiniu_RS_Copy($this->client, $this->bucket, $oldKey, $newBucket, $newKey); if ($err !== null) { throw new QiniuCopyException($err->Err, $err->Code, $key); } else { return true; } }