json - How to upload mutiple files using Spring RestController -
i have spring restcontroller bean, , add call recieves following structure:
- file file1 - integer integer2 - map<customclass,file> remainingfilesmapping
i tried creating dto object corresponds structure, couldn't figure out how create corresponding json message on client side (for me it's angular js application)
you can't put file json message. instead, have use content type multipart/form-data
explained in question: how http file upload work?
to make work angularjs, need module: file upload using angularjs
note many modern uis upload file in background , submit rest of form via ajax + json. means need 2 different controllers in spring (or @ least 2 methods) , persistence store can keep either piece until other ready.
to give example, need save json somewhere (file, database) until file upload has finished. @ time, must read json again saved , process file rest of information.
but if user takes long time fill in rest of form, file might ready, first. need able handle case well.
Comments
Post a Comment