I have a Jersey REST service to which data will be posted. There will be a a CSV file which is the actual data and some meta-data for that CSV (the meta can either be in JSO
You should use some multipart format. It basically consists of a single message of type multipart/xxx (where xxx can be something like form-data), and that message consists of other "complete" messages with their own content-type and other meta data.
You haven't specified which Jersey version, but starting with Jersey 2.x.x, there is multipart support available, in the form of a separate artifact:
org.glassfish.jersey.media
jersey-media-multipart
${jersey.version}
Then you just need to register the feature, as seen here in Registration.
Then you can just use @FormDataParam
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({MediaType.APPLICATION_JSON})
public CreateTaskVO provideService(
@FormDataParam("meta") String jsonMeta,
@FormDataParam("data") InputStream file,
@FormDataParam("data") FormDataContentDisposition fileDetail) {
You can see here an example of how the data can be sent from the client, and also the internal message body format of a multipart
Other rreading:
UPDATE
There is also support for multipart in Jersey 1.x.x, in the form of this artifact
com.sun.jersey.contribs
jersey-multipart
${jersey.version}