I've seen a number of examples on how to do this with only one file, but I'd like to accept two lists of files over a single REST call and reference each list by name. I'm using this as my method:
@POST
@Path("/initialize")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public String initialize(MultiPart data) {
List<File> maps = new ArrayList<>();
List<File> contexts = new ArrayList<>();
for(BodyPart bodyPart : data.getBodyParts()){
String name = bodyPart.getContentDisposition().getParameters().get("name");
if(name != null && name.equals("maps")){
//get the files from this bodyPart and add them to maps
} else if (name != null && name.equals("contexts")){
//get the files from this bodyPart and add them to contexts
}
}
return "foo";
}
Can anyone help me make the final step here and get the actual input streams out of the bodyParts? They have a getEntity() field, but I'm not sure that's what I'm looking for.