Skip to content

Commit 196927e

Browse files
authored
Merge pull request #94 from iamseojin/ocr-connect-develop
[fix] RecipeController OCR 이미지 업로드 및 OcrClient WebClient multipart 처리 개선
2 parents a6ecfd4 + 05b8c01 commit 196927e

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

yechef/src/main/java/sejong/capston/yechef/domain/Recipe/ai/OcrClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.springframework.http.client.MultipartBodyBuilder;
1111
import org.springframework.stereotype.Component;
1212
import org.springframework.web.multipart.MultipartFile;
13+
import org.springframework.web.reactive.function.BodyInserters;
1314
import org.springframework.web.reactive.function.client.WebClient;
1415
import sejong.capston.yechef.domain.Gpt.dto.RecipeParseResultDto;
1516

@@ -53,7 +54,7 @@ public String getFilename() {
5354
return webClient.post()
5455
.uri("/api/ocr")
5556
.contentType(MediaType.MULTIPART_FORM_DATA)
56-
.bodyValue(builder.build())
57+
.body(BodyInserters.fromMultipartData(builder.build()))
5758
.retrieve()
5859
.bodyToMono(new ParameterizedTypeReference<Map<String, List<String>>>() {})
5960
.map(map -> String.join("\n", map.getOrDefault("texts", List.of())))

yechef/src/main/java/sejong/capston/yechef/domain/Recipe/controller/RecipeController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public ResponseEntity<RecipeDto> createRecipe(
4848
// DetailRecipeDto result = recipeService.createRecipeFromImage(memberId, imageFile);
4949
// return ResponseEntity.ok(result);
5050
// }
51-
@PostMapping("/ocr/create")
51+
@PostMapping(value = "/ocr/create", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
5252
public ResponseEntity<OcrRecipeResultDto> createRecipeFromImage(
5353
@RequestParam("memberId") Long memberId,
5454
@RequestPart("image") MultipartFile imageFile) {

0 commit comments

Comments
 (0)