Using latest version of aws-sdk-php, while uploading object to s3. Getting
"error": {
"type": 1,
"message": "Uncaught Error: Call to undefined method AwsCommand::getMetricsBuilder() in /var/www/html/vendor/aws/aws-sdk-php/src/EndpointV2/EndpointV2Middleware.php:415
Stack trace:
#0 /var/www/html/vendor/aws/aws-sdk-php/src/EndpointV2/EndpointV2Middleware.php(106): AwsEndpointV2EndpointV2Middleware->appendEndpointMetrics()
#1 /var/www/html/vendor/aws/aws-sdk-php/src/Auth/AuthSelectionMiddleware.php(97): AwsEndpointV2EndpointV2Middleware->__invoke()
#2 /var/www/html/wp-content/plugins/w3-total-cache/vendor/aws/aws-sdk-php/src/InputValidationMiddleware.php(73): AwsAuthAuthSelectionMiddleware->__invoke()
#3 /var/www/html/vendor/aws/aws-sdk-php/src/Middleware.php(90): AwsInputValidationMiddleware->__invoke()
#4 /var/www/html/wp-content/plugins/w3-total-cache/vendor/aws/aws-sdk-php/src/S3/S3Client.php(639): AwsMiddleware::Aws{closure}()
#5 /var/www/html/wp-content/plugins/w3-total-cache/vendor/aws/aws-sdk-php/src/S3/S3Client.php(662): AwsS3S3Client::AwsS3{closure}()
#6 /var/www/html/wp-content/plugins/w3-total-cache/vendor/aws/aws-sdk-php/src/S3/S3Client.php(596): AwsS3S3Client::AwsS3{closure}()
#7 /var/www/html/wp-content/plugins/w3-total-cache/vendor/aws/aws-sdk-php/src/S3/S3Client.php(615): AwsS3S3Client::AwsS3{closure}()
#8 /var/www/html/vendor/aws/aws-sdk-php/src/Middleware.php(58): AwsS3S3Client::AwsS3{closure}()
#9 /var/www/html/wp-content/plugins/w3-total-cache/vendor/aws/aws-sdk-php/src/S3/SSECMiddleware.php(59): AwsMiddleware::Aws{closure}()
#10 /var/www/html/vendor/aws/aws-sdk-php/src/IdempotencyTokenMiddleware.php(77): AwsS3SSECMiddleware->__invoke()
#11 /var/www/html/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(64): AwsIdempotencyTokenMiddleware->__invoke()
#12 /var/www/html/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(58): AwsAwsClient->executeAsync()
#13 /var/www/html/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(86): AwsAwsClient->execute()
#14 /var/www/html/wp-content/plugins/w3-total-cache/CdnEngine_S3.php(402): AwsAwsClient->__call()
Code below
$this->api = new \Aws\S3\S3Client( array( 'credentials' => $credentials, 'region' => Cdn_Core::get_region_id( $this->_config['bucket_location'] ), 'version' => '2006-03-01', 'use_arn_region' => true, ) ); $result = $this->api->putObject( array( 'Bucket' => $this->_config['bucket'], 'Key' => $key, 'Body' => $key ) );
I tried import use Aws\S3\S3Client; but still error persists
Fixed it by updating the vendor folder of W3 total cache with the latest version of aws-sdk-php.