diff --git a/src/Client.php b/src/Client.php index d58e140..1bbe217 100644 --- a/src/Client.php +++ b/src/Client.php @@ -297,15 +297,25 @@ public function listFiles(array $options) // B2 returns, at most, 1000 files per "page". Loop through the pages and compile an array of File objects. while (true) { + $json = [ + 'bucketId' => $options['BucketId'], + 'startFileName' => $nextFileName, + 'maxFileCount' => $maxFileCount, + ]; + + if (isset($options['prefix'])) { + $json['prefix'] = $options['prefix']; + } + + if (isset($options['delimiter'])) { + $json['delimiter'] = $options['delimiter']; + } + $response = $this->client->request('POST', $this->apiUrl.'/b2_list_file_names', [ 'headers' => [ 'Authorization' => $this->authToken ], - 'json' => [ - 'bucketId' => $options['BucketId'], - 'startFileName' => $nextFileName, - 'maxFileCount' => $maxFileCount, - ] + 'json' => $json ]); foreach ($response['files'] as $file) {