private static Connector createClient(Map<String, Object> cfg) {
String url = (String) cfg.get("url");
String accessKey = (String) cfg.get("accessKey");
String secretKey = (String) cfg.get("secretKey");
String bucketName = (String) cfg.get("bucketName");
Supplier<AmazonS3> client = () -> {
log.info("createClient -> connecting to {}...", url);
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
AmazonS3 s3 = AmazonS3ClientBuilder.standard()
.withClientConfiguration(new ClientConfiguration())
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(url, "other-v2-signature"))
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.enablePathStyleAccess()
.build();
try {
createBucket(s3, bucketName);
} catch (Exception e) {
log.error("createClient -> error while creating buckets", e);
throw e;
}
return s3;
};
return new Connector(client, bucketName);
}