How can i use existing S3Client
-
I’m using some php functions to carry out other operations (unrelated to Offload functions) on files in my bucket for which I need an $s3Client instance.
I can’t work out how to use Offload’s existing client connection rather than creating a new client myself – this is my working code:$MyCreds = unserialize(AS3CF_SETTINGS); // Defined in wp-config.php
$provider = $MyCreds[‘provider’];
$key = $MyCreds[‘access-key-id’];
$secret = $MyCreds[‘secret-access-key’];//Create a S3Client
$s3Client = new Aws\S3\S3Client([
‘version’ => ‘latest’,
‘region’ => ‘eu-west-2’
]);$s3 = $s3Client::factory(array(
‘version’ => ‘latest’,
‘region’ => ‘eu-west-2’,
‘credentials’ => array(
‘provider’ => $provider,
‘key’ => $key,
‘secret’ => $secret
)
));$result = $s3->listBuckets();
foreach ($result[‘Buckets’] as $bucket)
{
echo $bucket[‘Name’] . ‘<br>’;
}Obviously, it would be nice if I could use the existing connection.
I’ve been trying stuff like:
$s3 = $as3cf->get_s3client;
But just can’t figure it out.
Any help much appreciated.
Thanks.
- The topic ‘How can i use existing S3Client’ is closed to new replies.