My requirement is to download large file from server using rest API, I am using java with Jersey framework and MULTIPART_FORM_DATA type for sending and receiving the file. API is working fine, but the problem is at client side when I do response.readEntity(FormDataMultiPart.class) it copies the entire multipart data in java's "java.io.tmpdir" folder. Is there any way to avoid it or any api/configuration to change jersey multipart temp directory path (other than "java.io.tmpdir").
Below is my sample client code:
Invocation.Builder invocationBuilder = webTarget.request(MediaType.MULTIPART_FORM_DATA_TYPE);
Response response = invocationBuilder.get();
FormDataMultiPart objMultiPart = response.readEntity(FormDataMultiPart.class);
List<BodyPart> listBodyPart = objMultiPart.getBodyParts();
try(FileOutputStream out = new FileOutputStream(filePath.toFile(), true)){
for(BodyPart part : listBodyPart) {
//code to process each bodypart
}
}