[Jersey] Re: how to upload large file more then 2 gb using jersey?

From: adnan.maks <>
Date: Tue, 28 Feb 2012 22:43:49 -0800 (PST)

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 -

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,
                        formData.bodyPart(new FormDataBodyPart("file1", veryLargeFile,

String xmlString =

View this message in context:
Sent from the Jersey mailing list archive at