Added array keys for space and file listing

This commit is contained in:
David Wakelin 2021-08-16 16:00:08 +01:00
parent f9b49002c7
commit cfea1967ab
11 changed files with 41 additions and 27 deletions

View file

@ -10,6 +10,7 @@ use SpacesAPI\Exceptions\FileDoesntExistException;
* You wouldn't normally instantiate this class directly,
* Rather obtain an instance from `\SpacesAPI\Space::list()`, `\SpacesAPI\Spaces::file()`, `\SpacesAPI\Spaces::uploadText()` or `\SpacesAPI\Spaces::uploadFile()`
*
* @property string $filename
* @property string $expiration
* @property string $e_tag
* @property int $last_modified

View file

@ -252,16 +252,16 @@ class Space
])
);
if (!isset($data['Contents'])) {
return ['files' => []];
}
$files = [
'files' => $data['Contents'],
'files' => [],
];
foreach ($files['files'] as $index => $fileInfo) {
$files['files'][$index] = new File($this, $fileInfo['Key'], $fileInfo);
if (!isset($data['Contents'])) {
return $files;
}
foreach ($data['Contents'] as $fileInfo) {
$files['files'][$fileInfo['Key']] = new File($this, $fileInfo['Key'], $fileInfo);
}
if (isset($data["NextContinuationToken"]) && $data["NextContinuationToken"] != "") {

View file

@ -61,7 +61,7 @@ class Spaces
$spaces = [];
foreach (Result::parse($this->s3->listBuckets()['Buckets']) as $bucket) {
$spaces[] = new Space($this->s3, $bucket['Name']);
$spaces[$bucket['Name']] = new Space($this->s3, $bucket['Name']);
}
return $spaces;