Skip to content

Commit

Permalink
Allow listing files by bucket name
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris White committed Feb 18, 2016
1 parent 6d45eca commit 39eac63
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ public function download(array $options)

/**
* Retrieve a collection of File objects representing the files stored inside a bucket.
* // @TODO: allow specifying bucket via its name.
*
* @param array $options
* @return array
Expand All @@ -267,6 +266,10 @@ public function listFiles(array $options)
$nextFileName = null;
$files = [];

if (!isset($options['BucketId']) && isset($options['BucketName'])) {
$options['BucketId'] = $this->getBucketIdFromName($options['BucketName']);
}

// B2 returns, at most, 1000 files per "page". Loop through the pages and compile an array of File objects.
while (true) {
$response = $this->client->request('POST', $this->apiUrl.'/b2_list_file_names', [
Expand Down

0 comments on commit 39eac63

Please sign in to comment.