From 4febee15878d7b307a3e35aa19af0d46ae22dfc5 Mon Sep 17 00:00:00 2001 From: yesjuhee Date: Sat, 23 Nov 2024 19:17:33 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20getFile=20API=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/scg/stop/StopApplication.java | 2 +- .../stop/file/service/MinioClientService.java | 25 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/scg/stop/StopApplication.java b/src/main/java/com/scg/stop/StopApplication.java index 1a658fac..352a63aa 100644 --- a/src/main/java/com/scg/stop/StopApplication.java +++ b/src/main/java/com/scg/stop/StopApplication.java @@ -10,4 +10,4 @@ public static void main(String[] args) { SpringApplication.run(StopApplication.class, args); } -} \ No newline at end of file +} diff --git a/src/main/java/com/scg/stop/file/service/MinioClientService.java b/src/main/java/com/scg/stop/file/service/MinioClientService.java index fd9c26e9..ffa62596 100644 --- a/src/main/java/com/scg/stop/file/service/MinioClientService.java +++ b/src/main/java/com/scg/stop/file/service/MinioClientService.java @@ -1,25 +1,25 @@ package com.scg.stop.file.service; -import static com.scg.stop.global.exception.ExceptionCode.FAILED_TO_GET_FILE; -import static com.scg.stop.global.exception.ExceptionCode.FAILED_TO_UPLOAD_FILE; - import com.scg.stop.global.exception.InternalServerErrorException; import io.minio.GetObjectArgs; import io.minio.MinioClient; import io.minio.PutObjectArgs; -import io.minio.errors.MinioException; -import java.io.InputStream; -import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import java.io.InputStream; +import java.text.Normalizer; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import static com.scg.stop.global.exception.ExceptionCode.FAILED_TO_GET_FILE; +import static com.scg.stop.global.exception.ExceptionCode.FAILED_TO_UPLOAD_FILE; + @Slf4j @Service @RequiredArgsConstructor @@ -52,12 +52,13 @@ public void uploadFile(MultipartFile file, UUID uuid, LocalDateTime createdAt) { public InputStream getFile(String uuid) { try { + String normalizedUuid = Normalizer.normalize(uuid, Normalizer.Form.NFD); // MinIO는 내부적으로 NFD 방식 사용 return minioClient.getObject( GetObjectArgs.builder() .bucket(bucketName) - .object(uuid) + .object(normalizedUuid) .build()); - } catch(Exception e) { + } catch (Exception e) { log.error(e.getMessage(), e); throw new InternalServerErrorException(FAILED_TO_GET_FILE); }