diff --git a/src/GoogleCloudStorage/GoogleCloudStorageAdapter.php b/src/GoogleCloudStorage/GoogleCloudStorageAdapter.php index e9614589c..59ae20805 100644 --- a/src/GoogleCloudStorage/GoogleCloudStorageAdapter.php +++ b/src/GoogleCloudStorage/GoogleCloudStorageAdapter.php @@ -305,12 +305,15 @@ public function storageObjectToStorageAttributes(StorageObject $object): Storage return new FileAttributes($path, $fileSize, null, $lastModified, $mimeType, $info); } - public function listContents(string $path, bool $deep): iterable + public function listContents(string $path, bool $deep, array $options = []): iterable { + $asPrefix = $options['listContentsAsPrefix'] ?? false; + $prefixedPath = $this->prefixer->prefixPath($path); - $prefixes = $options = []; - if ($prefixedPath !== '') { + if ($asPrefix) { + $options = ['prefix' => $prefixedPath]; + } elseif ($prefixedPath !== '') { $options = ['prefix' => sprintf('%s/', rtrim($prefixedPath, '/'))]; }