java - How to read uploaded file details in Jersey -
i have implemented rest service upload multiple files server.but problem can not file details if use formdatamultipart
in rest service.i can file content.like wise tried file details following , gave me error saying not supported.
@post @consumes(mediatype.multipart_form_data) public void upload(formdatamultipart formparams) { map<string, list<formdatabodypart>> fieldsbyname = formparams.getfields(); //assume sending files request (list<formdatabodypart> fields : fieldsbyname.values()) { (formdatabodypart field : fields) { inputstream = field.getentityas(inputstream.class); string filename = field.getname(); field.getmediatype(); //those work //this gave me error formdatacontentdisposition f=field.getentityas(formdatacontentdisposition .class); system.out.println(f.getfilename()); } } }
please let me know how can files details type,name,size
each uploaded files if use formdatamultipart
.
i able access file details here code snippet.
@post @consumes(mediatype.multipart_form_data) public void upload(formdatamultipart formparams) { map<string, list<formdatabodypart>> fieldsbyname = formparams.getfields(); //assume sending files request (list<formdatabodypart> fields : fieldsbyname.values()) { (formdatabodypart field : fields) { inputstream = field.getentityas(inputstream.class); string filename = field.getname(); field.getmediatype(); //this working fine formdatacontentdisposition f=field.getformdatacontentdisposition(); system.out.println(f.getfilename()); } } }
Comments
Post a Comment