1
1
package org .dynmap .storage .aws_s3 ;
2
2
3
3
import java .io .IOException ;
4
+ import java .net .URI ;
4
5
import java .nio .charset .StandardCharsets ;
5
6
import java .security .MessageDigest ;
6
7
import java .security .NoSuchAlgorithmException ;
@@ -221,7 +222,7 @@ public String toString() {
221
222
}
222
223
223
224
private String bucketname ;
224
- private String region ;
225
+ private Region region ;
225
226
private String access_key_id ;
226
227
private String secret_access_key ;
227
228
private String prefix ;
@@ -248,10 +249,20 @@ public boolean init(DynmapCore core) {
248
249
}
249
250
// Get our settings
250
251
bucketname = core .configuration .getString ("storage/bucketname" , "dynmap" );
251
- region = core .configuration .getString ("storage/region" , "us-east-1" );
252
252
access_key_id = core .configuration .getString ("storage/aws_access_key_id" , System .getenv ("AWS_ACCESS_KEY_ID" ));
253
253
secret_access_key = core .configuration .getString ("storage/aws_secret_access_key" , System .getenv ("AWS_SECRET_ACCESS_KEY" ));
254
254
prefix = core .configuration .getString ("storage/prefix" , "" );
255
+
256
+ // Either use a custom region, or one of the default AWS regions
257
+ String region_name = core .configuration .getString ("storage/region" , "us-east-1" );
258
+ String region_endpoint = core .configuration .getString ("storage/override_endpoint" , "" );
259
+
260
+ if (region_endpoint .length () > 0 ) {
261
+ region = Region .of (region_name , URI .create (region_endpoint ));
262
+ } else {
263
+ region = Region .fromString (region_name );
264
+ }
265
+
255
266
if ((prefix .length () > 0 ) && (prefix .charAt (prefix .length ()-1 ) != '/' )) {
256
267
prefix += '/' ;
257
268
}
@@ -763,7 +774,7 @@ private S3Client getConnection() throws S3Exception, StorageShutdownException {
763
774
if (cpoolCount < POOLSIZE ) { // Still more we can have
764
775
c = new DefaultS3ClientBuilder ()
765
776
.credentialsProvider (() -> AwsBasicCredentials .create (access_key_id , secret_access_key ))
766
- .region (Region . fromString ( region ) )
777
+ .region (region )
767
778
.httpClient (URLConnectionSdkHttpClient .create ())
768
779
.build ();
769
780
if (c == null ) {
0 commit comments