curena
4/17/2017 - 10:39 PM

Build local Minio S3 client using AWS Java SDK

Build local Minio S3 client using AWS Java SDK

AmazonS3 localS3Client(String localS3Address) {
		BasicAWSCredentials credentials = new BasicAWSCredentials(minioAccessKey, minioSecretKey);
		STSSessionCredentialsProvider sessionCredentialsProvider = new STSSessionCredentialsProvider(credentials);
		ClientConfiguration clientConfiguration = new ClientConfiguration();
		clientConfiguration.setSignerOverride("AWSS3V4SignerType");
		return AmazonS3ClientBuilder.standard().withCredentials(sessionCredentialsProvider)
				.withClientConfiguration(clientConfiguration)
				.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(
						"http://" + localS3Address + ":9000", "us-east-1"))
				.withPathStyleAccessEnabled(true).build();
}