Is it possible to upload file with additional data (like description etc.) with use of multipart/form-data
? I'm using backbone.js in my frontend and I call REST api with it (jQuery).
I don't use any view resolver but I want to somehow pass my file to controller like:
@RequestMapping(value = "/image/upload", method = RequestMethod.POST)
public String upload(UploadItem uploadItem, HttpSession session)
so that uploadItem stores:
private String desctiption;
private List<CommonsMultipartFile> fileData;
But I'm not adding (and I can't) this to my model.
Of course I'm also interested if it's possible to have controller like:
@RequestMapping(value = "/image/upload", method = RequestMethod.POST)
public String upload(someFileType uploadItem, String desctiption)
Yes you can pass the other form fields also along with multi part data. You can check the field name and use it like. (if (item.getName().equals("desctiption"))).