Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added s3_uploads_s3_client filter to be able to change the S3Client #603

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SeBsZ
Copy link

@SeBsZ SeBsZ commented Sep 8, 2022

We added the ability to filter the S3Client returned by the s3() function. This allows us to switch the S3Client and provide it with different credentials, region and endpoint. We have a site where not all files are stored on the same S3 provider, and using the sample function below then gives us the ability to load another set of credentials. It would be great if you could merge this functionality in the main repo.

Sample function:

add_filter('s3_uploads_s3_client', function ($client)
{
    //Create new S3Client with other params
    $params = [ 'version' => 'latest' ];
    $params['credentials']['key'] = self::$s3_key;
    $params['credentials']['secret'] = self::$s3_secret;
    $params['signature'] = 'v4';
    $params['region'] = self::$s3_region;
    $params['endpoint'] = self::$s3_endpoint;
    $params['use_path_style_endpoint'] = true;
    $params['debug'] = false;

    $client = null;
    $sdk = new Aws\Sdk( $params );
    $client = $sdk->createS3();

    return $client;
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant