요청 데이터
header={ authorization=, content-length=135022, referer=http://localhost:3000/, accept-language=ko-KR,ko;q=0.9, en-US;q=0.8, en;q=0.7, o rigin=http://localhost:3000, host={ip}:8080, //ip는 지웠습니다. connection=keep-alive, content-type=multipart/form-data; boundary=----WebKitFormBoundaryXgDJxgrLc2ZG8t6b, accept-encoding=gzip, deflate, accept=application/json, text/plain, */*, user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36 }
error log
[2021-12-04 17:52:33.253] [d-PLEKRAUQD][stdout]2021-12-04 17:52:33.252 ERROR 16536 --- [http-nio-8080-exec-1] c.p.m.c.e.GlobalExceptionHandler : handleException [2021-12-04 17:52:33.253] [d-PLEKRAUQD][stdout] [2021-12-04 17:52:33.253] [d-PLEKRAUQD][stdout]org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/octet-stream' not supported [2021-12-04 17:52:33.253] [d-PLEKRAUQD][stdout] at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:206) [2021-12-04 17:52:33.253] [d-PLEKRAUQD][stdout] at org.springframework.web.servlet.mvc.method.annotation.RequestPartMethodArgumentResolver.resolveArgument(RequestPartMethodArgumentResolver.java:138) [2021-12-04 17:52:33.253] [d-PLEKRAUQD][stdout] at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121) [2021-12-04 17:52:33.253] [d-PLEKRAUQD][stdout] at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:179)
client code
const response = await axios({ method: 'post', url: `http://ip/series/users/4`, headers: { Authorization: '', 'Content-Type': 'multipart/form-data', }, data: formData, }); const formData = new FormData(); formData.append('thumbnail', file); formData.append('request', JSON.stringify(request));
server code ver1
@PostMapping("/users/{userId}") @Operation(summary = "시리즈 공고 게시글 작성") @Tag(name = "[화면]-시리즈") public ApiResponse<SeriesSubscribePost.Response> postSeries( @PathVariable Long userId, @RequestPart MultipartFile thumbnail, @Valid @RequestPart SeriesSubscribePost.Request request) throws IOException { return ApiResponse.ok(HttpMethod.POST, seriesService.createSeries(userId, thumbnail, request)); }
server code ver2
@PostMapping(path = "/users/{userId}", consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }) @Operation(summary = "시리즈 공고 게시글 작성") @Tag(name = "[화면]-시리즈") public ApiResponse<SeriesSubscribePost.Response> postSeries( @PathVariable Long userId, @ModelAttribute SeriesSubscribePost.Thumbnail thumbnail, @Valid @RequestPart SeriesSubscribePost.Request request) throws IOException { return ApiResponse.ok( HttpMethod.POST, seriesService.createSeries(userId, thumbnail.thumbnail(), request)); }