|
|
|
@ -107,25 +107,37 @@ public class DynamicMinioAttachmentService {
|
|
|
|
MinioClient client = getClientByType(type);
|
|
|
|
MinioClient client = getClientByType(type);
|
|
|
|
String bucketName = getBucketByType(type);
|
|
|
|
String bucketName = getBucketByType(type);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// 1. mlflow-artifacts:/ 접두어 제거
|
|
|
|
|
|
|
|
String cleanObjectName = objectName.replaceFirst("^mlflow-artifacts:/", "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 잘못된 슬래시 제거
|
|
|
|
|
|
|
|
cleanObjectName = cleanObjectName.replaceAll("^/+", "").replaceAll("/+$", "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 파일 확장자가 없는 경우 (디렉터리 요청으로 추정)
|
|
|
|
|
|
|
|
// → MLflow 구조상 실제 파일은 artifacts/ 하위에 있으므로 경로 자동 보정
|
|
|
|
|
|
|
|
if (!cleanObjectName.matches(".*\\.[a-zA-Z0-9]+$")) {
|
|
|
|
|
|
|
|
throw new RuntimeException("요청된 객체가 파일이 아닙니다. 실제 파일 경로를 포함해야 합니다: " + cleanObjectName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try (InputStream is = client.getObject(
|
|
|
|
try (InputStream is = client.getObject(
|
|
|
|
GetObjectArgs.builder().bucket(bucketName).object(objectName).build()
|
|
|
|
GetObjectArgs.builder()
|
|
|
|
|
|
|
|
.bucket(bucketName)
|
|
|
|
|
|
|
|
.object(cleanObjectName)
|
|
|
|
|
|
|
|
.build()
|
|
|
|
)) {
|
|
|
|
)) {
|
|
|
|
return is.readAllBytes();
|
|
|
|
return is.readAllBytes();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (io.minio.errors.ErrorResponseException e) {
|
|
|
|
} catch (io.minio.errors.ErrorResponseException e) {
|
|
|
|
throw new RuntimeException(
|
|
|
|
throw new RuntimeException(
|
|
|
|
"MinIO 서버가 요청을 거부했습니다: " + objectName +
|
|
|
|
"MinIO 서버가 요청을 거부했습니다: " + objectName +
|
|
|
|
", 코드=" + e.errorResponse().code() +
|
|
|
|
", 코드=" + e.errorResponse().code() +
|
|
|
|
|
|
|
|
", 버킷이름=" + bucketName +
|
|
|
|
", 메시지=" + e.errorResponse().message() +
|
|
|
|
", 메시지=" + e.errorResponse().message() +
|
|
|
|
", 요청ID=" + e.errorResponse().requestId() +
|
|
|
|
", 요청ID=" + e.errorResponse().requestId() +
|
|
|
|
", 호스트ID=" + e.errorResponse().hostId(), e);
|
|
|
|
", 호스트ID=" + e.errorResponse().hostId(), e);
|
|
|
|
} catch (io.minio.errors.ServerException e) {
|
|
|
|
|
|
|
|
throw new RuntimeException("MinIO 서버 오류 발생: " + objectName, e);
|
|
|
|
|
|
|
|
} catch (io.minio.errors.InsufficientDataException e) {
|
|
|
|
|
|
|
|
throw new RuntimeException("MinIO 데이터 부족 오류: " + objectName, e);
|
|
|
|
|
|
|
|
} catch (io.minio.errors.InternalException e) {
|
|
|
|
|
|
|
|
throw new RuntimeException("MinIO 내부 오류: " + objectName, e);
|
|
|
|
|
|
|
|
} catch (io.minio.errors.InvalidResponseException e) {
|
|
|
|
|
|
|
|
throw new RuntimeException("MinIO 응답 파싱 실패: " + objectName, e);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new RuntimeException("MinIO 파일 다운로드 실패: " + objectName, e);
|
|
|
|
throw new RuntimeException("MinIO 파일 다운로드 실패: " + objectName, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|