mardi 21 avril 2015

How to list bucket objects without returning structure object using listObjects in PHP?

With the following code, I get a 39 meg response with 443,588 lines which contains a whole lot of useless information thanks to the structure object with a slew of function definitions with descriptions and accepted attributes.

This is obviously way more information that wanted when just trying to list the bucket contents, and 39 megs for each request is insane for a list of 1000 objects. There is a protected object in the returned Guzzle\Service\Resource\Model Object that contains the results I'm looking for called data:protected and an array within called contents.

use Aws\Common\Aws;
use Aws\Common\Enum\Size;
use Aws\S3\Enum\CannedAcl;
use Aws\S3\Exception\S3Exception;

$s3 = Aws::factory($awsConfig)->get('s3');
$res = $s3->listObjects(array('Bucket' => <bucket_name>));




Aucun commentaire:

Enregistrer un commentaire