From d019012c2723723e37901e2a8c46898263445605 Mon Sep 17 00:00:00 2001 From: sycuuui <102959791+sycuuui@users.noreply.github.com> Date: Mon, 6 May 2024 20:39:29 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20mosaic=20video=20test=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/video/service/VideoService.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/capic/server/domain/video/service/VideoService.java b/src/main/java/com/capic/server/domain/video/service/VideoService.java index 347ef6b..1d7a634 100644 --- a/src/main/java/com/capic/server/domain/video/service/VideoService.java +++ b/src/main/java/com/capic/server/domain/video/service/VideoService.java @@ -224,24 +224,31 @@ public ResponseEntity sendToFlaskWithImagesAndVideoTest(String folderN List imageContents = new ArrayList<>(); for (String imageName : videoReq.imageName()) { // 이미지 파일 가져오기 - S3ObjectInputStream imageFile = s3Client.get(folderName + "/" + imageName); - byte[] imageContent = IOUtils.toByteArray(imageFile); - imageContents.add(imageContent); + for(int i=0;i<3;i++){ + String imagePath = folderName + "/" + imageName+"/"+(i+1)+".jpeg"; + System.out.println(imagePath); + S3ObjectInputStream imageFile = s3Client.get(imagePath); + byte[] imageContent = IOUtils.toByteArray(imageFile); + imageContents.add(imageContent); + } + System.out.println("finish"); } - + System.out.println("check"); +// return videoReq.videoName(); // Multipart 요청 생성 MultiValueMap body = new LinkedMultiValueMap<>(); + System.out.println("check2"); body.add("video", new ByteArrayResource(videoContent) { @Override public String getFilename() { return videoReq.videoName(); // 동영상 파일 이름 가져오기 } }); - + System.out.println("check3"); // 이미지 파일들을 요청에 추가 for (int i = 0; i < imageContents.size(); i++) { byte[] content = imageContents.get(i); - final String imageName = videoReq.imageName().get(i); + final String imageName = i +".jpeg"; body.add("image" + (i + 1), new ByteArrayResource(content) { @Override public String getFilename() { @@ -249,9 +256,10 @@ public String getFilename() { } }); } + System.out.println("check4"); body.add("imageSize",imageContents.size()); - + System.out.println("check5"); // HTTP 요청 설정 HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.MULTIPART_FORM_DATA); @@ -259,7 +267,7 @@ public String getFilename() { // Flask 서버로 요청 보내기 RestTemplate restTemplate = new RestTemplate(); - String url = "http://13.124.110.226:5000/video"; // Flask 서버 URL + String url = "http://127.0.0.1:5000/video"; // Flask 서버 URL ResponseEntity response = restTemplate.postForEntity(url, requestEntity, byte[].class); // Flask에서 반환된 파일을 다시 클라이언트에게 반환