diff --git a/src/main/java/me/lucko/bytebin/Bytebin.java b/src/main/java/me/lucko/bytebin/Bytebin.java index 3f6f9c5..55c34ae 100644 --- a/src/main/java/me/lucko/bytebin/Bytebin.java +++ b/src/main/java/me/lucko/bytebin/Bytebin.java @@ -186,7 +186,7 @@ public Bytebin(Configuration config) throws Exception { // schedule invalidation task if (expiryHandler.hasExpiryTimes() || metrics) { - this.executor.scheduleWithFixedDelay(storageHandler::runInvalidationAndRecordMetrics, 5, 60 * 5, TimeUnit.SECONDS); + this.executor.scheduleWithFixedDelay(storageHandler::runInvalidationAndRecordMetrics, 5, 5, TimeUnit.MINUTES); } if (config.getBoolean(Option.AUDIT_ON_STARTUP, false)) { diff --git a/src/main/java/me/lucko/bytebin/content/storage/S3Backend.java b/src/main/java/me/lucko/bytebin/content/storage/S3Backend.java index 2251dbb..2d07f65 100644 --- a/src/main/java/me/lucko/bytebin/content/storage/S3Backend.java +++ b/src/main/java/me/lucko/bytebin/content/storage/S3Backend.java @@ -33,6 +33,7 @@ import software.amazon.awssdk.core.ResponseInputStream; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.services.s3.S3Client; +import software.amazon.awssdk.services.s3.S3ClientBuilder; import software.amazon.awssdk.services.s3.model.DeleteObjectRequest; import software.amazon.awssdk.services.s3.model.GetObjectRequest; import software.amazon.awssdk.services.s3.model.GetObjectResponse; @@ -44,6 +45,7 @@ import software.amazon.awssdk.services.s3.model.S3Object; import software.amazon.awssdk.services.s3.paginators.ListObjectsV2Iterable; +import java.net.URI; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -68,7 +70,14 @@ public S3Backend(String backendId, String bucketName) { this.bucketName = bucketName; // configure with environment variables: AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY - this.client = S3Client.builder().build(); + S3ClientBuilder builder = S3Client.builder(); + + String s3EndpointUrl = System.getenv("AWS_S3_ENDPOINT_URL"); + if (s3EndpointUrl != null && !s3EndpointUrl.isBlank()) { + builder = builder.endpointOverride(URI.create(s3EndpointUrl)); + } + + this.client = builder.build(); } @Override