vendredi 28 août 2015

Get presigned url of all objects in bucket amazon aws s3

I am trying to get pre-signed url of all object in bucket. I am using amazon php sdk version 3.

What I have tried is

$client = new Aws\S3\S3Client([
    'version' => 'latest',
    'region' => 'us-west-2',
    'credentials.ini' => [
        'key' => $credentials['key'],
        'secret' => $credentials['secret'],
    ],
]);

$client->listObjects(['Bucket' => $bucketName]);

Above get me all object in arrayAccess but It have object url like

 http://ift.tt/1PCp7kp

and I don't want that everyone have access to one2.txt so I have created a preassigned url by

$cmd = $client->getCommand('GetObject', [
    'Bucket' => $bucket,
    'Key'    => $key
]);
$request = $client->createPresignedRequest($cmd, '+20 minutes');

$presignedUrl = (string) $request->getUri();

echo $presignedUrl;

Now I am getting url with token

http://ift.tt/1EoMc9P

which Is exactly what I want but Now my question is

How to get preassigned url all items in bucket rather than making for all item one by one ?




Aucun commentaire:

Enregistrer un commentaire