Multipart File upload Spring Boot

前端 未结 6 818
栀梦
栀梦 2020-11-29 23:48

Im using Spring Boot and want to use a Controller to receive a multipart file upload. When sending the file I keep getting the error 415 unsupported content type

6条回答
  •  温柔的废话
    2020-11-30 00:23

    @RequestBody MultipartFile[] submissions
    

    should be

    @RequestParam("file") MultipartFile[] submissions
    

    The files are not the request body, they are part of it and there is no built-in HttpMessageConverter that can convert the request to an array of MultiPartFile.

    You can also replace HttpServletRequest with MultipartHttpServletRequest, which gives you access to the headers of the individual parts.

提交回复
热议问题