Skip to content

Commit

Permalink
Merge pull request #31 from russellxrs/master
Browse files Browse the repository at this point in the history
Filter out directory when list object
  • Loading branch information
overtrue authored Mar 28, 2023
2 parents fe4374c + 9b84399 commit 27da0c9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/CosAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,13 @@ protected function listObjects(string $directory = '', bool $recursive = false)
if (($index = \key($result[$key])) !== 0) {
$result[$key] = \is_null($index) ? [] : [$result[$key]];
}

//过滤掉目录
if ($key === 'Contents') {
$result[$key] = \array_filter($result[$key], function ($item) {
return ! \str_ends_with($item['Key'], '/');
});
}
}

return $result;
Expand Down

0 comments on commit 27da0c9

Please sign in to comment.