I also have a requirement to upload multiple large files using jersey. So, I
chose multipart file transfer. However, I am getting an exception at the
server end. I think it is because of the jersey container trying to load the
entire multipart file contents into MimeMultipart object that the OOM error
is thrown. I want a methodology with which I can save the files to some
temporary directory(do I have to implement a MessageReader/Writer?) and not
loaded into Java memory.
My server code looks like below -
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_XML)
@Path("multipartTransfer")
public EventStatus fileTransferInviteMultiPart(MimeMultipart data) throws
IOException, MessagingException, ClassNotFoundException {
--some InputSTream code goes here
}
My client code looks like below -
FormDataMultiPart formData = new FormDataMultiPart();
if (veryLargeFile != null) {
char[] metadataBytes = new char[100];
metadataBytes = "this is file metadata".toCharArray();
formData.bodyPart(new FormDataBodyPart("file1_metadata", metadataBytes,
MediaType.MULTIPART_FORM_DATA_TYPE));
formData.bodyPart(new FormDataBodyPart("file1", veryLargeFile,
MediaType.APPLICATION_OCTET_STREAM_TYPE));
}
String xmlString =
service.path("rest").path("fileTransfer").path("multipartTransfer").type(MediaType.MULTIPART_FORM_DATA).accept(MediaType.APPLICATION_XML).post(String.class,formData);
--
View this message in context: http://jersey.576304.n2.nabble.com/how-to-upload-large-file-more-then-2-gb-using-jersey-tp7283481p7328264.html
Sent from the Jersey mailing list archive at Nabble.com.