mercredi 4 mars 2015

mutipart with json using spring rest

Following is the code snippet i am using for file upload with additional data using spring rest api


@RequestMapping(value = "/artman", method = RequestMethod.POST, consumes = { "multipart/mixed" }) public @ResponseBody void uploadCustomAnnotationFile(@RequestPart("file") MultipartFile uploadFile, @RequestPart("model") TestModel model) {


It works perfectly fine with the following curl


curl -H "Content-Type: multipart/mixed" -H "Authorization: bearer aac5752e-9e54-43ed-b915-228f377c626c" -F "model=@/usr/local/temp/simple_json.json; type=application/json " -F "file=@/usr/local/temp/tomcat.gif" -X POST http://localhost:8089/my-project/test/image


where the content of simple_json.json is as below


{ "name":"micheal"}


I want to send the above json data in the curl itself rather than keeping it in a file.Please let me know what is the change required in code or in curl


Thanks in advance


Aucun commentaire:

Enregistrer un commentaire