Ejemplo n.º 1
0
 public function testBatchDeleteMoveCopy()
 {
     $key2 = 'testOp2' . getTid();
     $key3 = 'testOp3' . getTid();
     $key4 = 'testOp4' . getTid();
     $e1 = new Qiniu_RS_EntryPath($this->bucket, $this->key);
     $e2 = new Qiniu_RS_EntryPath($this->bucket, $key2);
     $e3 = new Qiniu_RS_EntryPath($this->bucket, $key3);
     $e4 = new Qiniu_RS_EntryPath($this->bucket, $key4);
     Qiniu_RS_BatchDelete($this->client, array($e2, $e3, $e4));
     $entryPairs = array(new Qiniu_RS_EntryPathPair($e1, $e2), new Qiniu_RS_EntryPathPair($e1, $e3));
     list($ret, $err) = Qiniu_RS_BatchCopy($this->client, $entryPairs);
     $this->assertNull($err);
     $this->assertEquals($ret[0]['code'], 200);
     $this->assertEquals($ret[1]['code'], 200);
     list($ret, $err) = Qiniu_RS_BatchMove($this->client, array(new Qiniu_RS_EntryPathPair($e2, $e4)));
     $this->assertNull($err);
     $this->assertEquals($ret[0]['code'], 200);
     list($ret, $err) = Qiniu_RS_BatchDelete($this->client, array($e3, $e4));
     $this->assertNull($err);
     $this->assertEquals($ret[0]['code'], 200);
     $this->assertEquals($ret[1]['code'], 200);
     Qiniu_RS_BatchDelete($this->client, array($e2, $e3, $e4));
 }
Ejemplo n.º 2
0
$key3 = $key1 . '3';
$e3 = new Qiniu_RS_EntryPath($bucket, $key3);
# @endgist
# @gist batch_stat
$entries = array($e1, $e2);
list($ret, $err) = Qiniu_RS_BatchStat($client, $entries);
echo "\n\n====> Qiniu_RS_BatchStat result: \n";
if ($err !== null) {
    var_dump($err);
} else {
    var_dump($ret);
}
# @endgist
# @gist batch_copy
$entryPairs = array(new Qiniu_RS_EntryPathPair($e1, $e2), new Qiniu_RS_EntryPathPair($e1, $e3));
list($ret, $err) = Qiniu_RS_BatchCopy($client, $entryPairs);
echo "\n\n====> Qiniu_RS_BatchCopy result: \n";
if ($err !== null) {
    var_dump($err);
} else {
    var_dump($ret);
}
# @endgist
# @gist batch_delete
$entries = array($e1, $e2);
list($ret, $err) = Qiniu_RS_BatchDelete($client, $entries);
echo "\n\n====> Qiniu_RS_BatchDelete result: \n";
if ($err !== null) {
    var_dump($err);
} else {
    var_dump($ret);
Ejemplo n.º 3
0
 public function batchCopy(array $pairs)
 {
     $keys = func_get_args();
     if (func_num_args() <= 0) {
         return array();
     }
     $entries = array();
     foreach ($keys as $i => $key) {
         if (isset($key['from']) and !empty($key['from']) and isset($key['to']) and !empty($key['to'])) {
             $key['from'] = new \Qiniu_RS_EntryPath($this->bucket, $key['from']);
             $key['to'] = new \Qiniu_RS_EntryPath($this->bucket, $key['to']);
             $entries[$i] = new \Qiniu_RS_EntryPathPair($key['from'], $key['to']);
         } else {
             $entries[$i] = new \Qiniu_RS_EntryPathPair(new \Qiniu_RS_EntryPath($this->bucket, 'empty'), new \Qiniu_RS_EntryPath($this->bucket, 'empty'));
         }
     }
     list($ret, $err) = Qiniu_RS_BatchCopy($client, $entries);
     if ($err !== null) {
         $ret['code'] = $err->Code;
         return $ret;
     } else {
         return $ret;
     }
 }