diff --git a/pom.xml b/pom.xml index 2d19925..d9f3692 100644 --- a/pom.xml +++ b/pom.xml @@ -16,8 +16,8 @@ http://s3ninja.net - dev-31.1.0 - dev-52.1.1 + dev-33.1.0 + dev-57.3.0 @@ -55,7 +55,7 @@ com.amazonaws aws-java-sdk-s3 - 1.12.261 + 1.12.307 diff --git a/src/main/java/ninja/Bucket.java b/src/main/java/ninja/Bucket.java index 961eaf8..249f741 100644 --- a/src/main/java/ninja/Bucket.java +++ b/src/main/java/ninja/Bucket.java @@ -307,7 +307,7 @@ public List getObjects(@Nullable String query, Limit limit) { .filter(currentFile -> isMatchingObject(query, currentFile)) .filter(limit.asPredicate()) .map(StoredObject::new) - .collect(Collectors.toList()); + .toList(); } catch (IOException e) { throw Exceptions.handle(e); } diff --git a/src/main/java/ninja/S3Dispatcher.java b/src/main/java/ninja/S3Dispatcher.java index 16dec33..e0f5625 100644 --- a/src/main/java/ninja/S3Dispatcher.java +++ b/src/main/java/ninja/S3Dispatcher.java @@ -137,16 +137,6 @@ private static class S3Request { .withChronology(IsoChronology.INSTANCE) .withZone(ZoneOffset.ofHours(0)); - /** - * RFC 822 date/time formatter. - */ - public static final DateTimeFormatter RFC822_INSTANT = - new DateTimeFormatterBuilder().appendPattern("EEE, dd MMM yyyy HH:mm:ss 'GMT'") - .toFormatter() - .withLocale(Locale.ENGLISH) - .withChronology(IsoChronology.INSTANCE) - .withZone(ZoneOffset.ofHours(0)); - private static final Map headerOverrides; static { @@ -658,10 +648,10 @@ private void deleteObject(final WebContext webContext, final Bucket bucket, fina object.markDeleted(); } catch (IOException ignored) { signalObjectError(webContext, - bucket.getName(), - id, - S3ErrorCode.InternalError, - Strings.apply("Error while marking file as deleted")); + bucket.getName(), + id, + S3ErrorCode.InternalError, + Strings.apply("Error while marking file as deleted")); return; } } @@ -794,7 +784,8 @@ private void getObject(WebContext webContext, Bucket bucket, String id, boolean StoredObject object = bucket.getObject(id); if (!object.exists() && !object.isMarkedDeleted() && awsUpstream.isConfigured()) { URL fetchURL = awsUpstream.generateGetObjectURL(bucket, object, sendFile); - Consumer requestTuner = requestBuilder -> requestBuilder.setMethod(sendFile ? "GET" : "HEAD"); + Consumer requestTuner = + requestBuilder -> requestBuilder.setMethod(sendFile ? "GET" : "HEAD"); webContext.enableTiming(null).respondWith().tunnel(fetchURL.toString(), requestTuner, null, null); return; } @@ -829,7 +820,7 @@ private void getObject(WebContext webContext, Bucket bucket, String id, boolean String contentType = MimeHelper.guessMimeType(object.getFile().getName()); response.addHeader(HttpHeaderNames.CONTENT_TYPE, contentType); response.addHeader(HttpHeaderNames.LAST_MODIFIED, - RFC822_INSTANT.format(Instant.ofEpochMilli(object.getFile().lastModified()))); + Response.RFC822_INSTANT.format(Instant.ofEpochMilli(object.getFile().lastModified()))); response.addHeader(HttpHeaderNames.CONTENT_LENGTH, object.getFile().length()); response.status(HttpResponseStatus.OK); } @@ -967,7 +958,7 @@ private void completeMultipartUpload(WebContext webContext, .stream() .sorted(Comparator.comparing(Map.Entry::getKey)) .map(Map.Entry::getValue) - .collect(Collectors.toList())); + .toList()); file.deleteOnExit(); if (!file.exists()) { diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 4ac65c7..7d35c34 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -42,6 +42,25 @@ storage { awsSecretKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" } +# Configures an upstream S3 instance which can be used in case an object is not found locally. +upstreamAWS { + # The secret key to connect to the upstream S3 instance. + secretKey = "" + + # The access key to connect to the upstream S3 instance. + accessKey = "" + # The endpoint used to connect to the upstream S3 instance. + endPoint = "" + + # The signing region used to connect to the upstream S3 instance. + # If not given, the value "EU" is used. + signingRegion = "" + + # The signer type used to connect to the upstream S3 instance. + # This config is optional and will be ignored if missing. + signerType = "" +} + cache { public-bucket-access { maxSize = 128