Spring Boot Upload Multipart 413 Request Entity Too Large

雨燕双飞 提交于 2019-12-06 15:39:08

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!