mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-01 21:31:36 +02:00
Allow configuration of AWS region
This commit is contained in:
@@ -21,16 +21,29 @@ public class S3SwapStore implements SwapStore {
|
||||
this(
|
||||
cfg.getAwsAccessKey(),
|
||||
cfg.getAwsSecret(),
|
||||
cfg.getS3BucketName()
|
||||
cfg.getS3BucketName(),
|
||||
cfg.getAwsRegion()
|
||||
);
|
||||
}
|
||||
|
||||
S3SwapStore(
|
||||
String accessKey,
|
||||
String secret,
|
||||
String bucketName
|
||||
String bucketName,
|
||||
String region
|
||||
) {
|
||||
s3 = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secret))).build();
|
||||
String regionToUse = null;
|
||||
if (region == null) {
|
||||
regionToUse = "us-east-1";
|
||||
} else {
|
||||
regionToUse = region;
|
||||
}
|
||||
s3 = AmazonS3ClientBuilder
|
||||
.standard()
|
||||
.withRegion(regionToUse)
|
||||
.withCredentials(
|
||||
new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secret))
|
||||
).build();
|
||||
this.bucketName = bucketName;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ public class SwapStoreConfig {
|
||||
"noop",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
@@ -16,19 +17,22 @@ public class SwapStoreConfig {
|
||||
private String awsAccessKey;
|
||||
private String awsSecret;
|
||||
private String s3BucketName;
|
||||
private String awsRegion;
|
||||
|
||||
public SwapStoreConfig() {}
|
||||
|
||||
public SwapStoreConfig(
|
||||
String awsAccessKey,
|
||||
String awsSecret,
|
||||
String s3BucketName
|
||||
String s3BucketName,
|
||||
String awsRegion
|
||||
) {
|
||||
this(
|
||||
"s3",
|
||||
awsAccessKey,
|
||||
awsSecret,
|
||||
s3BucketName
|
||||
s3BucketName,
|
||||
awsRegion
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,12 +40,14 @@ public class SwapStoreConfig {
|
||||
String type,
|
||||
String awsAccessKey,
|
||||
String awsSecret,
|
||||
String s3BucketName
|
||||
String s3BucketName,
|
||||
String awsRegion
|
||||
) {
|
||||
this.type = type;
|
||||
this.awsAccessKey = awsAccessKey;
|
||||
this.awsSecret = awsSecret;
|
||||
this.s3BucketName = s3BucketName;
|
||||
this.awsRegion = awsRegion;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
@@ -60,12 +66,15 @@ public class SwapStoreConfig {
|
||||
return s3BucketName;
|
||||
}
|
||||
|
||||
public String getAwsRegion() { return awsRegion; }
|
||||
|
||||
public SwapStoreConfig sanitisedCopy() {
|
||||
return new SwapStoreConfig(
|
||||
type,
|
||||
awsAccessKey == null ? null : "<awsAccessKey>",
|
||||
awsSecret == null ? null : "<awsSecret>",
|
||||
s3BucketName
|
||||
s3BucketName,
|
||||
awsRegion
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user