/** * @param string $bucket * @return string */ public function listAction($bucket) { $errors = []; $buckets = []; try { $result = $this->s3Client->listBuckets(); $buckets = $result->get('Buckets'); } catch (S3Exception $e) { $errors[] = sprintf('Cannot retrieve buckets: %s', $e->getMessage()); } $objects = []; if (!empty($bucket)) { try { $maxIteration = 10; $iteration = 0; $marker = ''; do { $result = $this->s3Client->listObjects(['Bucket' => $bucket, 'Marker' => $marker]); if ($result->get('Contents')) { $objects = array_merge($objects, $result->get('Contents')); } if (count($objects)) { $marker = $objects[count($objects) - 1]['Key']; } } while ($result->get('IsTruncated') && ++$iteration < $maxIteration); if ($result->get('IsTruncated')) { $errors[] = sprintf('The number of keys greater than %u, the first part is shown', count($objects)); } } catch (S3Exception $e) { $errors[] = sprintf('Cannot retrieve objects: %s', $e->getMessage()); } } return $this->twig->render('list.html.twig', ['selected_bucket' => $bucket, 'buckets' => $buckets, 'objects' => $objects, 'errors' => $errors]); }
/** * List all containers, just names if noted * * @param bool $include_properties If true, additional properties are retrieved * * @throws \Exception * @return array */ public function listContainers($include_properties = false) { $this->checkConnection(); if (!empty($this->container)) { return $this->listResource($include_properties); } /** @noinspection PhpUndefinedMethodInspection */ $buckets = $this->blobConn->listBuckets()->get('Buckets'); $out = []; foreach ($buckets as $bucket) { $name = rtrim($bucket['Name']); $out[] = ['name' => $name, 'path' => $name]; } return $out; }
/** * @depends testHeadBucket */ public function testGetService() { $result = $this->client->listBuckets(); $this->assertNotEmpty($result['Owner']); $this->assertNotEmpty($result['Owner']['ID']); $this->assertNotEmpty($result['Owner']['DisplayName']); $this->assertNotEmpty($result['Buckets']); $found = false; foreach ($result['Buckets'] as $bucket) { if ($bucket['Name'] == $this->bucket) { $found = true; break; } } $this->assertTrue($found); }
/** * Returns a list of all buckets owned by the authenticated sender of the request. * Available keys: Name, CreationDate * @return mixed */ public function listBuckets() { return $this->instance->listBuckets(); }
<?php if ($message != '') { ?> <p class="bg-warning"><?php echo $message; ?> </p> <?php } ?> <form method="POST" action="" enctype="multipart/form-data"> <div class="form-group"> <label for="exampleInputFile">Choose Bucket</label> <select name="bucket" class="form-control"> <?php $buckets = $s3->listBuckets(); foreach ($buckets['Buckets'] as $bucket) { echo '<option value="' . $bucket['Name'] . '">' . $bucket['Name'] . '</option>'; } ?> </select> </div> <div class="form-group"> <label for="exampleInputFile">File upload</label> <input type="file" name="uploadfile" id="exampleInputFile" class="form-control"> </div> <input type="submit" name="submit" class="btn btn-primary" value="Upload Image" /> </form> </div> <div class="col-md-1"></div> </div>
/** * @return mixed */ public function listBuckets() { $buckets = $this->s3Client->listBuckets(); return $buckets["Buckets"]; }
public function listBuckets() { $result = $this->s3->listBuckets(); return $result['Buckets']; }
echo $message; ?> </p> <?php } ?> <table class="table"> <tr> <th>Bucket</th> <th>File Name</th> <th>Download Link</th> <th>Resized Image</th> </tr> <?php $result = $s3->listBuckets(); foreach ($result['Buckets'] as $bucket) { // Each Bucket value will contain a Name and CreationDate if ($s3->doesObjectExist($bucket['Name'], SMALLIMAGELIST_FILE)) { $txtfile = $s3->getObject(['Bucket' => $bucket['Name'], 'Key' => SMALLIMAGELIST_FILE]); $txtbody = $txtfile['Body']; $lines = explode(PHP_EOL, $txtbody); foreach ($lines as $key) { if (trim($key) != '') { $tag = preg_split("/######/", $key); echo '<tr>'; echo '<td>' . $bucket['Name'] . '</td>'; echo '<td>' . $tag[1] . '</td>'; echo '<td><a href="' . S3_PATH . $bucket['Name'] . '/' . $tag[1] . '">Click</a></td>'; echo '<td><a href="' . S3_PATH . $bucket['Name'] . '/' . $tag[2] . '"><img src="' . S3_PATH . $bucket['Name'] . '/' . $tag[2] . '"/></a></td>'; echo '</tr>';