How to remove HTTP artifacts from a multidisciplinary request for form data?

I have this method signature in jersery servlet. The servlet is reached and the form data is present in the uploadedInputStream object, but the stream does not have http artifacts removed from it. See below.

@POST @Produces("text/plain") @Consumes(MediaType.MULTIPART_FORM_DATA) public String uploadFileIE( @FormDataParam("qqfile") InputStream uploadedInputStream ){ } 

When stored in a file, the input stream contains these artifacts surrounding the byte data:

 -----------------------------7dc1f42e3005a8 Content-Disposition: form-data; name="qqfile";filename="[filename]" Content-Type: application/octet-stream [bytes from data stream] -----------------------------7dc1f42e3005a8-- 

Shouldn't these artifacts be deleted at this point? Is there an easy way to remove them without reinventing the wheel?

+3
java jersey file-upload multipartform-data
source share
1 answer

With Jersey, you need to β€œconsume” additional header information using the FormDataContentDisposition object. Ruthlessly, but necessary:

 @POST @Produces("text/plain") @Consumes(MediaType.MULTIPART_FORM_DATA) public String uploadFileIE( @FormDataParam("qqfile") InputStream uploadedInputStream, @FormDataParam("qqfile") FormDataContentDisposition fileDetail){ } 
+4
source

All Articles