rest - Extra info in pdf content sent as MULTIPART-FORMDATA in RESTFUL(JERSEY) -


while uploading pdf/text file using jersey client, information being appended original pdf file.(i using jersey glassfish api client)

below content getting appended original file when saved in server:

  --boundary_1_10166575_1464163574882    content-type: text/plain    content-disposition: form-data; name="foo" bar     --boundary_1_10166575_1464163574882     content-type: application/pdf     content-disposition: form-data; filename="abc.pdf"; modification-date="tue, 03 may 2016 06:34:59 gmt"; size=109494; name="inputpdffile" 

========================================================================= refer below client source code:

        final client client = clientbuilder.newbuilder()                 .register(multipartfeature.class).build();          final filedatabodypart filepart = new filedatabodypart(                 "inputpdffile", new file(                         "c:/test/abc.pdf"));         formdatamultipart formdatamultipart = new formdatamultipart();         final formdatamultipart multipart = (formdatamultipart) formdatamultipart                 .field("foo", "bar").bodypart(filepart);          final webtarget target = client                 .target("http://localhost:7001/restfulservice/resources/pdfuploadtest");         final response response = target.request().post(                 entity.entity(multipart, multipart.getmediatype())); 

======================================================================== refer below server source code:

@post @path("/pdfuploadtest") @consumes(mediatype.multipart_form_data)     public response uploadfile(     @formdataparam("inputpdffile") inputstream encodedpdfdata,     @formdataparam("inputpdffile") formdatacontentdisposition filedetail) {             outputstream out = new fileoutputstream(new                                     file("c:/test/success.pdf"));          byte[] bytearray = new byte[1024];         if (null != encodedpdfdata) {             while ((x = encodedpdfdata.read(bytearray)) != -1) {                 out.write(bytearray,0,x);             }         }         out.flush();         out.close();     } 


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -