• Resolved huemanfoo


    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.


Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor ianmjones


    We do not support using WP Offload Media in this way at the moment, and you may suffer serious issues after updates to WP Offload Media as those internal functions you’re reaching into the plugin to use may change.

    We may in the future create a public API for WP Offload Media that allows you to use WP Offload Media’s functionality programmatically, but that’s likely a good ways off as yet.

    You might want to take a look at https://wordpress.org/plugins/amazon-web-services/, but fair warning, we no longer work on it and it uses AWS PHP SDK v2 rather than the current v3.

    Otherwise I recommend using the AWS PHP SDK v3 yourself within a custom plugin.



    Thanks for the headsup. Yea i saw your older plugin but wouldn’t do what i was hoping.
    I’m not actually reaching into the plugin, rather, all I’m doing is using same credentials and same sdk rather than installing another.
    Theway i have it works well, i just thought maybe rather than creating a new client, i could use your one but its not a problem, just for convenience.
    Anyway, ill keep it as i have, thanks again!



    Resolved, cheers 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can i use existing S3Client’ is closed to new replies.