I have such a method:
@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody
@PreAuthorize(\"@securityService.isAllow
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.