java - How can I get request from the client with JSON data and fileupload via JAX-RS(Jersey)? -


i need request client json data , image file in single request via jax-rs. how can receive in server side java application process further.

@post @path("/path") @consumes({mediatype.application_json, mediatype.multipart_form_data}) public string get(@context uriinfo uriinfo,         final mydto mydto,         @formdataparam("file") final inputstream inputstream,         @formdataparam("file") final formdatacontentdisposition filedetail) { } 

i having above code not working expected.

this code working project. send file data , meta. try same.

    @post     @path("import")     @consumes(mediatype.multipart_form_data)     @produces(mediatype.application_json + "; charset=utf-8")     @rolesallowed(systemroles.admin)     public void importscenario(@formdataparam("importscenario") final inputstream is,             @formdataparam("complectid") final long complectid) {         log.debug("start import file");         if (is == null) {             throw new illegalargumentexception(messagebundle.get(innermessage.no_file));         }         try {             log.debug("start execute import bean");             importservice.importscenarioorcomplect(is, complectid);             log.debug("end execute import bean");         } catch (filestorageexception e) {             throw new illegalargumentexception(e);         } catch (stcoreexception e) {             throw new ejbexception(messagebundle.get(innermessage.critical_error), e);         } {             log.debug("end import file");         }     } 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -