Skip to content

Commit

Permalink
Support for prefix and delimiter in listing files.
Browse files Browse the repository at this point in the history
  • Loading branch information
jawngee committed Jan 10, 2019
1 parent 331210b commit b21028a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b21028a

Please sign in to comment.