My Requirement is to send the file to the REST Service through one client. That service is going to process the file. I am using Jersey API for implementing this. But I have searched in many articles, there is no any information of how to pass the file from client side and how the REST service will retrieve the file... How to achieve this?
And I am not using the Servlets for Creating REST Service.
Am I right by assuming, since its a MimeMultipart type, that I could not just send one, but multiple files or additional information maybe as String or whatever, on doing only one simple post, just by adding multiple MimeBodyParts containing the different files or whatever? for example like:
etc.
Assuming you are using Jersey on both the client and server side, here is some code that you can extend:
Server side:
The above code implements a resource method that accepts POST's of multipart (file) data. It also illustrates how you can iterate through all the individual body parts in the incoming (multipart) request.
Client:
The above code simply attaches a file to a multipart request, and fires the request off to the server. For both client and server side code there is a reliance on the Jersey and JavaMail libraries. If you are using Maven, these can be pulled down with ease, with the following dependencies:
Adjust the dependency versions as required