|
|
|
@ -1,10 +1,13 @@
|
|
|
|
package kr.re.etri.autoflow.controllers;
|
|
|
|
package kr.re.etri.autoflow.controllers;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import io.minio.DownloadObjectArgs;
|
|
|
|
import io.minio.GetObjectArgs;
|
|
|
|
import io.minio.GetObjectArgs;
|
|
|
|
import io.minio.MinioClient;
|
|
|
|
import io.minio.MinioClient;
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
|
|
|
import jakarta.servlet.ServletOutputStream;
|
|
|
|
|
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
import kr.re.etri.autoflow.entity.MinioAttachmentEntity;
|
|
|
|
import kr.re.etri.autoflow.entity.MinioAttachmentEntity;
|
|
|
|
|
|
|
|
|
|
|
|
import kr.re.etri.autoflow.payload.request.ProjectBaseSearchRequest;
|
|
|
|
import kr.re.etri.autoflow.payload.request.ProjectBaseSearchRequest;
|
|
|
|
@ -13,14 +16,22 @@ import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springdoc.core.annotations.ParameterObject;
|
|
|
|
import org.springdoc.core.annotations.ParameterObject;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
|
|
|
import org.springframework.core.io.FileSystemResource;
|
|
|
|
|
|
|
|
import org.springframework.core.io.InputStreamResource;
|
|
|
|
|
|
|
|
import org.springframework.core.io.Resource;
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
import org.springframework.http.*;
|
|
|
|
import org.springframework.http.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
|
|
|
import java.nio.file.Files;
|
|
|
|
|
|
|
|
import java.nio.file.Path;
|
|
|
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
@ -101,6 +112,34 @@ public class MinioAttachmentController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/download_new")
|
|
|
|
|
|
|
|
public ResponseEntity<Resource> downloadFile_new(@RequestParam String objectName) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// MinIO에서 스트리밍으로 가져오기
|
|
|
|
|
|
|
|
InputStream is = minioClient.getObject(
|
|
|
|
|
|
|
|
GetObjectArgs.builder()
|
|
|
|
|
|
|
|
.bucket("mlpipeline")
|
|
|
|
|
|
|
|
.object(objectName)
|
|
|
|
|
|
|
|
.build()
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InputStreamResource resource = new InputStreamResource(is);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String encodedFileName = URLEncoder.encode(objectName, StandardCharsets.UTF_8)
|
|
|
|
|
|
|
|
.replaceAll("\\+", "%20");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok()
|
|
|
|
|
|
|
|
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename*=UTF-8''" + encodedFileName)
|
|
|
|
|
|
|
|
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
|
|
|
|
|
|
|
.body(resource);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.error("파일 다운로드 실패", e);
|
|
|
|
|
|
|
|
return ResponseEntity.internalServerError().build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "MinIO YAML 파일 읽기", description = "MinIO에서 YAML 파일을 다운로드하여 텍스트로 반환합니다.")
|
|
|
|
@Operation(summary = "MinIO YAML 파일 읽기", description = "MinIO에서 YAML 파일을 다운로드하여 텍스트로 반환합니다.")
|
|
|
|
@GetMapping(value = "/readYamlText", produces = MediaType.TEXT_PLAIN_VALUE)
|
|
|
|
@GetMapping(value = "/readYamlText", produces = MediaType.TEXT_PLAIN_VALUE)
|
|
|
|
public ResponseEntity<String> readYamlTextFromMinio(@RequestParam String objectName) {
|
|
|
|
public ResponseEntity<String> readYamlTextFromMinio(@RequestParam String objectName) {
|
|
|
|
|