IBM / ibm-cos-sdk-java

ibm-cos-sdk-java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example Code

JoeBall opened this issue · comments

Is the example code up-to-date ?
I get the error "method withCredentials is undefined for typeAmazonS3ClientBuilder"

code snippet:
AmazonS3 s3Client = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(credentials))
.withEndpointConfiguration(new EndpointConfiguration(endpoint_url, location)).withPathStyleAccessEnabled(true)
.withClientConfiguration(clientConfig).build();

The code looks valid. AmazonS3ClientBuilder has a method, withCredentials, that accepts a single argument of type AWSCredentialsProvider, (which AWSStaticCredentialsProvider is). There was a namespace change in version 2.0.0 of the sdk. So, for example, com.amazonaws.auth.AWSStaticCredentialsProvider became com.ibm.cloud.objectstorage.auth.AWSStaticCredentialsProvider. Might be worth double checking your import statements if using version 2.x of the sdk.

ok I see the method in AwsClientBuilder.

AmazonS3ClientBuilder extends AmazonS3Builder
AmazonS3Builder extends AwsSyncClientBuilder
AwsSyncClientBuilder extends AwsClientBuilder

My build had an error - but now it works . Thanks for the quick reply