Spring Boot Upload Multipart 413 Request Entity Too Large

前端 未结 1 1334
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-14 15:12

I have such a method:

@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody
@PreAuthorize(\"@securityService.isAllow         


        
相关标签:
1条回答
  • 2021-01-14 15:45

    Change @RequestPart(required = false) to @RequestParam("file", required = false) before MultipartFile media within your createPost method's argument list.

    I suspect that the type extracted from const { uri, type } = imageURI; is not multipart/form-data, but instead is something like image/jpeg.

    Despite the fact that your Headers section contains 'Content-Type': 'multipart/form-data', the part type likely does not correspond, and @RequestPart is unable to find an HttpMessageConverter to deal with the larger multi-part files.

    The @RequestParam annotation can also be used for multipart/form-data, and in your case it appears to be able to find an appropriate Converter.

    You could use some tool like Fiddler to review the actual data coming from your API call in order to verify my suspicions about the part type. Alternatively, you could add another argument to your createPost method (MultipartHttpServletRequest request) to gain access to the headers of the individual parts directly from within your Java code.

    0 讨论(0)
提交回复
热议问题