This is my web service's declaration
@POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces("application/json")
public DeviceDbUploadResponse upload(@FormDataParam("file1") InputStream file1,
@FormDataParam("file2") InputStream file2,
@FormDataParam("name1") String filename1,
@FormDataParam("name2") String filename2,
@FormDataParam("ID") String ID)
My web service call
var fd=new FormData();
fd.append("ID",ID);
/* lines of code here */
$.ajax({
url: 'http://localhost:8080/linterm2m/webapi/m2m/upload',
data: fd,
processData: false,
contentType: false,
type: 'POST'
});
Everything works well so far. Now it is required to receive all the data (filename and ID) through an Request Object, something like:
public class Request{
String ID;
String filename1;
String filename2;
}
But I doubt it can be fulfilled because of the multipart-form-data consuming type. I need some enlightenment and a solution.