In this example we are going to see how you can upload a File to a server using a JAX-RS REST Service using Jersey. Uploading a File using Jersey is fairly easy, as it uses all the HTTP infrastructure for file upload operations.
In this example we are going to use an HTML Form that has one input field of type
file. When the HTTP POST request is constructed, it will contain a media type of
multipart/form-data. The media-type
multipart/form-datafollows the rules of all multipart MIME data streams.
multipart/form-datacontains a number of parts, corresponding to the input parameters of the form. Each part contains a
content-dispositionheader where the disposition type is
form-data. The disposition, also contains a “
name” parameter, the value of which is the input field name in the HTML form and can be used to obtain this header in our service
reference http://examples.javacodegeeks.com/enterprise-java/rest/jersey/jersey-file-upload-example/ (here only the code)