From e7ef7f58717cde9b090104efe1bd7cb56508711b Mon Sep 17 00:00:00 2001 From: Afly Date: Wed, 13 Nov 2024 11:27:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=20fix:=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8BpreserveMetadata=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../s3/repository/core/S3ResourceRepository.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java b/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java index f8d05b3..c6edea8 100644 --- a/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java +++ b/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java @@ -175,15 +175,15 @@ public class S3ResourceRepository extends BaseResourceRepository { metadata = s3.getObjectMetadata(bucket, path); } catch (Exception ignore) { } - } - if (metadata == null) { - metadata = new ObjectMetadata(); - String mimeType = URLConnection.guessContentTypeFromName(path); - if (mimeType != null) { - metadata.setContentType(mimeType); + if (metadata == null) { + metadata = new ObjectMetadata(); + String mimeType = URLConnection.guessContentTypeFromName(path); + if (mimeType != null) { + metadata.setContentType(mimeType); + } } + metadata.setContentLength(length); } - metadata.setContentLength(length); s3.putObject(bucket, path, new ByteArrayInputStream(data), metadata); } }