|
|
|
|
@ -45,9 +45,6 @@ public class MinioAttachmentController {
|
|
|
|
|
|
|
|
|
|
private final MinioClient minioClient;
|
|
|
|
|
|
|
|
|
|
@Value("${kubeflow.url}")
|
|
|
|
|
private String kubeflowBaseUrl;
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "첨부파일 전체 조회")
|
|
|
|
|
@GetMapping
|
|
|
|
|
public ResponseEntity<List<MinioAttachmentEntity>> getAll() {
|
|
|
|
|
@ -93,12 +90,9 @@ public class MinioAttachmentController {
|
|
|
|
|
@Operation(summary = "파일 다운로드", description = "MinIO에서 파일을 다운로드합니다.")
|
|
|
|
|
@GetMapping("/download")
|
|
|
|
|
public ResponseEntity<byte[]> downloadFile(@RequestParam String objectName) {
|
|
|
|
|
try (InputStream is = minioClient.getObject(
|
|
|
|
|
GetObjectArgs.builder().bucket("mlpipeline").object(objectName).build()
|
|
|
|
|
)) {
|
|
|
|
|
byte[] bytes = is.readAllBytes();
|
|
|
|
|
try {
|
|
|
|
|
byte[] bytes = minioAttachmentService.downloadFile("mlpipeline", objectName);
|
|
|
|
|
|
|
|
|
|
// 파일명을 UTF-8로 URL 인코딩
|
|
|
|
|
String encodedFileName = URLEncoder.encode(objectName, StandardCharsets.UTF_8)
|
|
|
|
|
.replaceAll("\\+", "%20"); // 공백 처리
|
|
|
|
|
|
|
|
|
|
@ -106,6 +100,7 @@ public class MinioAttachmentController {
|
|
|
|
|
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename*=UTF-8''" + encodedFileName)
|
|
|
|
|
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
|
|
|
|
.body(bytes);
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("파일 다운로드 실패", e);
|
|
|
|
|
return ResponseEntity.internalServerError().build();
|
|
|
|
|
@ -143,18 +138,11 @@ public class MinioAttachmentController {
|
|
|
|
|
@Operation(summary = "MinIO YAML 파일 읽기", description = "MinIO에서 YAML 파일을 다운로드하여 텍스트로 반환합니다.")
|
|
|
|
|
@GetMapping(value = "/readYamlText", produces = MediaType.TEXT_PLAIN_VALUE)
|
|
|
|
|
public ResponseEntity<String> readYamlTextFromMinio(@RequestParam String objectName) {
|
|
|
|
|
try (InputStream is = minioClient.getObject(
|
|
|
|
|
GetObjectArgs.builder()
|
|
|
|
|
.bucket("mlpipeline")
|
|
|
|
|
.object(objectName)
|
|
|
|
|
.build()
|
|
|
|
|
)) {
|
|
|
|
|
// InputStream을 문자열로 변환 (UTF-8)
|
|
|
|
|
String content = new String(is.readAllBytes(), StandardCharsets.UTF_8);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String content = minioAttachmentService.readYamlText("mlpipeline", objectName);
|
|
|
|
|
return ResponseEntity.ok(content);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("MinIO 파일 읽기 실패: " + objectName, e);
|
|
|
|
|
log.error("MinIO 파일 읽기 실패: {}", objectName, e);
|
|
|
|
|
return ResponseEntity.internalServerError()
|
|
|
|
|
.body("Error reading file: " + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|