Gaufrette\Adapter\AwsS3::listKeys PHP Method

listKeys() public method

public listKeys ( $prefix = '' )
    public function listKeys($prefix = '')
    {
        $options = array('Bucket' => $this->bucket);
        if ((string) $prefix != '') {
            $options['Prefix'] = $this->computePath($prefix);
        } elseif (!empty($this->options['directory'])) {
            $options['Prefix'] = $this->options['directory'];
        }
        $keys = array();
        $iter = $this->service->getIterator('ListObjects', $options);
        foreach ($iter as $file) {
            $keys[] = $this->computeKey($file['Key']);
        }
        return $keys;
    }

Usage Example

Example #1
0
 public function shouldListKeysWithoutDirectory()
 {
     $client = $this->getClient();
     $adapter = new AwsS3($client, 'bucket', array('directory' => 'bar'));
     $adapter->write('test.txt', 'some content');
     $keys = $adapter->listKeys();
     $this->assertEquals('test.txt', $keys['key']);
 }