From 5900be72c779ad4401e12257a31fa4805338efe1 Mon Sep 17 00:00:00 2001 From: jixinchi Date: Wed, 25 Oct 2023 15:30:12 +0800 Subject: [PATCH] commonPrefixes is only for delimiter request --- .../java/org/gaul/s3proxy/S3ProxyHandler.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/gaul/s3proxy/S3ProxyHandler.java b/src/main/java/org/gaul/s3proxy/S3ProxyHandler.java index d2ca3cfe..a8d169a3 100644 --- a/src/main/java/org/gaul/s3proxy/S3ProxyHandler.java +++ b/src/main/java/org/gaul/s3proxy/S3ProxyHandler.java @@ -1506,8 +1506,11 @@ private void handleBlobList(HttpServletRequest request, case FOLDER: // fallthrough case RELATIVE_PATH: - commonPrefixes.add(metadata.getName()); - continue; + if (delimiter != null) { + commonPrefixes.add(metadata.getName()); + continue; + } + break; default: break; } @@ -1528,10 +1531,15 @@ private void handleBlobList(HttpServletRequest request, writeSimpleElement(xml, "ETag", maybeQuoteETag(eTag)); } - writeSimpleElement(xml, "Size", - String.valueOf(metadata.getSize())); - writeSimpleElement(xml, "StorageClass", - StorageClass.fromTier(metadata.getTier()).toString()); + Long size = metadata.getSize(); + if (size != null) { + writeSimpleElement(xml, "Size", String.valueOf(size)); + } + + Tier tier = metadata.getTier(); + if (tier != null) { + writeSimpleElement(xml, "StorageClass", StorageClass.fromTier(tier).toString()); + } if (fetchOwner) { writeOwnerStanza(xml);