Skip to content

Commit 129fa7a

Browse files
committed
feat 增加列目录的示例
1 parent 4529c33 commit 129fa7a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

examples/list-all-file.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
require __DIR__ . '/../tests/bootstrap.php';
3+
4+
use Upyun\Config;
5+
use Upyun\Upyun;
6+
7+
$config = new Config(BUCKET, USER_NAME, PWD);
8+
$upyun = new Upyun($config);
9+
10+
$start = null;
11+
$total = 0;
12+
do {
13+
$list = $upyun->read('/', null, array(
14+
'X-List-Limit' => 100,
15+
'X-List-Iter' => $start,
16+
));
17+
18+
if (is_array($list['files'])) {
19+
foreach($list['files'] as $file) {
20+
$total++;
21+
if ($file['type'] === 'N') {
22+
echo '文件名: ';
23+
} else {
24+
echo '目录名: ';
25+
}
26+
echo $file['name'];
27+
echo ' 大小:' . $file['size'];
28+
echo ' 修改时间:' . date('Y-m-d H:i:s', $file['time']);
29+
echo "\n";
30+
}
31+
32+
}
33+
$start = $list['iter'];
34+
} while(!$list['is_end']);
35+
36+
echo '总共存有文件 ' . $total . '';

0 commit comments

Comments
 (0)