To use multipart features you need to add jersey-media-multipart module to your pom.xml file:
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.19</version>
</dependency>
Add MultiPartFeature in web.xml
Further, you are required to add MultiPartFeature in Jersey configuration to let it know that you will use multipart requests. Simplest way is to add support through web.xml file.
<p>Select a file : <inputtype="file"name="file"size="45"accept=".pdf"/></p>
<inputtype="submit"value="Upload PDF"/>
</form>
</body>
</html>
Now hit the URL : “http://localhost:8080/JerseyDemos/fileUpload.html” and it will display a HTML file control to browse the file. Select any PDF file and click on “Upload PDF” button.
Your file will be uploaded and you will get the message: “Data uploaded successfully !!”
Test file upload using java client
If you are looking for uploading files using java clients then you can modify below working code as per your need.