I want to save an entity in DB. The entity has several fields and photo (photo I will save in byte[]). I wrote a RestController
, but it hasn't worked.
Format JSON
, I use postman, in form-data
I add a file, in raw I put body and use JSON
.
@RequestMapping(value = "/upload", method = RequestMethod.POST, consumes = {"multipart/form-data"})
@ResponseBody
public void storeAd(@RequestPart("client") @Valid Client client, @RequestPart("file") @Valid MultipartFile file) throws IOException {
Client myClient = client;
byte[] s = file.getBytes();
int a = s.length;
}
I see error: Resolved exception caused by handler execution:
org.springframework.web.HttpMediaTypeNotSupportedException:
Content type 'application/json' not supported
Request from postman1