Home » Java » Receive Multipart FormData – Jersey 1.19.1 REST

Receive Multipart FormData – Jersey 1.19.1 REST

Posted by: admin October 26, 2017 Leave a comment

Questions:

I am sending multipart/form-data request but I am unable to get FormData values in Jersey 1.19.1 as @FormDataParam is not available. I am trying with the following code but I got strucked. Is there a way to resolve it in this Jersey version?

@POST
@Path("/uploadfile")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public String uploadFile(@Context HttpContext hc) {
   HttpRequestContext request = hc.getRequest();

   return null;
}

Thanks in advance.

Answers:

Maybe you need this extension: https://mvnrepository.com/artifact/com.sun.jersey.contribs/jersey-multipart

i think in thex 1.x jersey universe this was seperated.

here is an example blog post:

https://puspendu.wordpress.com/2012/08/23/restful-webservice-file-upload-with-jersey/

https://www.mkyong.com/webservices/jax-rs/file-upload-example-in-jersey/