How to solve ‘Client is immutable when created with the builder’?

Question:

I am creating an application where want to upload a file to S3 bucket.
I am getting an error from following code snippet:

I am getting an error as:

What changes I should make to upload a file successfully to the required bucket?

Answer:

Obviously the error says that if you use the AmazonS3ClientBuilder to build a client, it will be immutable and you can’t modify it after it is built.

The solution is to remove later s3Client.setS3ClientOptions(...) and to set required options using the AmazonS3ClientBuilder builder. Something along the lines:

Leave a Reply