java - How to handle application/octet-stream contained in MULTIPART_FORM_DATA -
i trying implement rest endpoint able handle following post:
-----------------------------6739772541706953700536795627 content-disposition: form-data; name="flowchunknumber" 1 -----------------------------6739772541706953700536795627 content-disposition: form-data; name="flowchunksize" 1048576 -----------------------------6739772541706953700536795627 content-disposition: form-data; name="flowcurrentchunksize" 1474992 -----------------------------6739772541706953700536795627 content-disposition: form-data; name="flowtotalsize" 1474992 -----------------------------6739772541706953700536795627 content-disposition: form-data; name="flowidentifier" 1474992-sam_0391jpg -----------------------------6739772541706953700536795627 content-disposition: form-data; name="flowfilename" sam_0391.jpg -----------------------------6739772541706953700536795627 content-disposition: form-data; name="flowrelativepath" sam_0391.jpg -----------------------------6739772541706953700536795627 content-disposition: form-data; name="flowtotalchunks" 1 -----------------------------6739772541706953700536795627 content-disposition: form-data; name="file"; filename="sam_0391.jpg" content-type: application/octet-stream
therefore, try leverage org.glassfish.jersey.media.multipart.formdatamultipart looks this:
@post @path("/upload") @consumes(mediatype.multipart_form_data) public void uploadimage(formdatamultipart multipartdata).
at point i'am struggeling retrieving actual content of content-type: application/octet-stream. suggestions how can handle type of content?
thanks in advance
you use @formdataparam
annotations
@consumes(mediatype.multipart_form_data) public void uploadimage(@formdataparam("file") inputstream file)
or if want stick using formdatamultipart
, like
@consumes(mediatype.multipart_form_data) public void uploadimage(formdatamultipart multipartdata) { formdatabodypart filepart = multipartdata.getfield("file"); if (filepart != null) { inputstream file = filepart.getentityas(inputstream.class); } }
see:
- javadoc
formdatamultipart
idea of other things can programmatically.
Comments
Post a Comment