Skip to content

Commit 362b637

Browse files
committed
mkzip
1 parent 28cddf7 commit 362b637

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/Qiniu/Processing/PersistentFop.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,25 @@ public function __call($method, $args)
9191
array_push($ops, $pfop);
9292
return $this->execute($key, $ops);
9393
}
94+
95+
public function mkzip($dummy_key, $urls_and_alias,
96+
$to_bucket = null, $to_key = null, $mode = 2)
97+
{
98+
$base = 'mkzip/' . $mode;
99+
$op = array($base);
100+
foreach ($urls_and_alias as $key => $value) {
101+
if (is_int($key)) {
102+
array_push($op, 'url/' . \Qiniu\base64_urlSafeEncode($value));
103+
}else{
104+
array_push($op, 'url/' . \Qiniu\base64_urlSafeEncode($key));
105+
array_push($op, 'alias/' . \Qiniu\base64_urlSafeEncode($key));
106+
}
107+
}
108+
$fop = implode('/', $op);
109+
if ($to_bucket != null) {
110+
$op = Operation::saveas($fop, $to_bucket, $to_key);
111+
}
112+
$ops =array($op);
113+
return $this->execute($dummy_key, $ops);
114+
}
94115
}

tests/Qiniu/Tests/PfopTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testAvthumb()
3636
$this->assertNull($error);
3737
}
3838

39-
public function testMkzip()
39+
public function testExecute2()
4040
{
4141
global $testAuth;
4242
$pfop = new PersistentFop($testAuth, 'testres', 'sdktest', true);
@@ -54,4 +54,19 @@ public function testMkzip()
5454
$this->assertNotNull($status);
5555
$this->assertNull($error);
5656
}
57+
58+
public function testMkzip()
59+
{
60+
global $testAuth;
61+
$pfop = new PersistentFop($testAuth, 'testres', 'sdktest', true);
62+
$urls = array(
63+
'http://testres.qiniudn.com/gogopher.jpg' => 'g.jpg',
64+
'http://testres.qiniudn.com/gogopher.jpg'
65+
);
66+
list($id, $error) = $pfop->mkzip('sintel_trailer.mp4', $urls, 'phpsdk', 'mkziptest2.zip');
67+
$this->assertNull($error);
68+
list($status, $error) = PersistentFop::status($id);
69+
$this->assertNotNull($status);
70+
$this->assertNull($error);
71+
}
5772
}

0 commit comments

Comments
 (0)