Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] getFile API 오류 수정 #123

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/com/scg/stop/StopApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public static void main(String[] args) {
SpringApplication.run(StopApplication.class, args);
}

}
}
25 changes: 13 additions & 12 deletions src/main/java/com/scg/stop/file/service/MinioClientService.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
}
Expand Down
Loading