- if there's a way I can do it with this jaxrs-ri version
You need the jersey-media-multipart
. This has the multipart support. If you are using Maven, add
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.0.1</version> <!-- or whatever version
</dependency> you plan to use. -->
If you are not using Maven, you can find the download here. Scroll down and select the Jersey version you are using. Then click the Download (Jar) button to download. You will also need the mimepull
jar that goes with it. To find it, scroll down and click version button that goes with mimepull
.
- if it's mandatory to change jaxrs-ri version to a more recent one
Any 2.x version will have the multipart support in a different artifact, as mentioned above.
- how to use this annotation
First you will need to register the MultiPartFeature
. See here for help. Then just do something like
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response post(@FormDataParam("file") InputStream file) {
...
}
See Also (for details and examples):