Skip to content

Commit

Permalink
feat(storage): support IncludeFoldersAsPrefixes (#7053)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwarajanand authored Feb 15, 2024
1 parent 3ff327c commit 1e35432
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Storage/src/Bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,9 @@ public function object($name, array $options = [])
* from the prefix, contain delimiter will have their name,
* truncated after the delimiter, returned in prefixes. Duplicate
* prefixes are omitted.
* @type bool $includeFoldersAsPrefixes If true, will also include folders
* and managed folders (besides objects) in the returned prefixes.
* Only applicable if delimiter is set to '/'.
* @type int $maxResults Maximum number of results to return per
* request. **Defaults to** `1000`.
* @type int $resultLimit Limit the number of results returned in total.
Expand Down
22 changes: 22 additions & 0 deletions Storage/tests/Unit/BucketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,28 @@ public function testGetsObjectsWithToken()
$this->assertEquals('file2.txt', $objects[1]->name());
}

public function testGetsObjectsWithManagedFolders()
{
$this->connection->listObjects(Argument::any())
->willReturn([
'kind' => 'storage#objects',
'prefixes' => ['managedFolders/', 'mf/'],
'items' => [[
'name' => 'mf/file.txt',
'generation' => 'abc',
'kind' => 'storage#object'
]]
]);

$bucket = $this->getBucket();
$objects = iterator_to_array($bucket->objects([
'delimiter' => '/',
'includeFoldersAsPrefixes' => true
]));

$this->assertEquals('mf/file.txt', $objects[0]->name());
}

public function testDelete()
{
$bucket = $this->getBucket([], false);
Expand Down

0 comments on commit 1e35432

Please sign in to comment.