2

I tried implementing this way, but I get 415 Error if I send the request. I don't want to split it into two different request. I'm not sure what I am doing wrong.


    @ResponseStatus(value = HttpStatus.CREATED)
    @PostMapping(value = "/file/new",
            consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE})
    public ResponseEntity<DefaultResponseDto<Object>> createFile(HttpServletRequest servletRequest,
                                                                 @RequestBody @Valid
                                                                 PortfolioFileSaveRequestDto request,
                                                                 @RequestPart MultipartFile file) {
        List<String> tokenInfo = jwtProvider.authorizeJwt(servletRequest.getHeader(AUTHORIZATION));

        ...

        Portfolio portfolio = portfolioService.saveFile(request, user.getUsername(), profile, file);

        ...
    }
gs97ahn
  • 175
  • 9

1 Answers1

1

Add a field for the MultipartFile in PortfolioFileSaveRequestDto so you can handle all the data together.

Unmitigated
  • 76,500
  • 11
  • 62
  • 80