Skip to content

Commit

Permalink
#54 region
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Sep 5, 2017
1 parent 32fd4b5 commit 0aeb0e4
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/main/java/com/jcabi/s3/Region.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public interface Region {
*/
@Immutable
@ToString
@EqualsAndHashCode(of = { "key", "secret" })
@EqualsAndHashCode(of = { "key", "secret", "region" })
@Loggable(Loggable.DEBUG)
final class Simple implements Region {
/**
Expand All @@ -84,26 +84,43 @@ final class Simple implements Region {
* Secret.
*/
private final transient String secret;
/**
* Region.
*/
private final transient String region;
/**
* Public ctor.
* @param akey Amazon key
* @param scrt Amazon secret
*/
public Simple(final String akey, final String scrt) {
this(akey, scrt, "us-east-1");
}
/**
* Public ctor.
* @param akey Amazon key
* @param scrt Amazon secret
* @param rgn Region
*/
public Simple(final String akey, final String scrt, final String rgn) {
this.key = akey;
this.secret = scrt;
this.region = rgn;
}
@Override
public Bucket bucket(final String name) {
return new AwsBucket(this, name);
}
@Override
public AmazonS3 aws() {
return AmazonS3ClientBuilder.standard().withCredentials(
new AWSStaticCredentialsProvider(
new BasicAWSCredentials(this.key, this.secret)
return AmazonS3ClientBuilder.standard()
.withRegion(this.region)
.withCredentials(
new AWSStaticCredentialsProvider(
new BasicAWSCredentials(this.key, this.secret)
)
)
).build();
.build();
}
}
}

0 comments on commit 0aeb0e4

Please sign in to comment.