Send and receive large MTOMAttachments to IBM Content Manager WebService

517 views Asked by At

When trying to upload large files (100-500MB) I get the familiar "OutOfMemoryException" which is caused by trying to read the whole file into memory at once (asked and answered here on stackoverflow). I know that I should use a stream or divide the file into smaller parts. Changing the proxy code manually is an option, if that helps. I use the specific webservice (CMWebService).

Since I am unable to change IBMs code, is there any way to send the file in smaller parts? I have already found the classes UpdateItemRequestAdd and UpdateItemRequestAddPart but I can't get them to work. Unfortunately, there are also no samples available by IBM.

Receiving files pose the same problem, and I have not been able to find any classes that could help me there.

This is the code that I am currently using to upload files:

string resources0 = "tiffFileContent";
string resources1 = "image/tiff";
string resources2 = @"D:\myImageFile.tif";

CreateItemRequest createRequest = new CreateItemRequest()
{
    AuthenticationData = data,
    Item = new CreateItemRequestItem()
    {
        ItemXML = new ItemXML()
        {
            MYITEMTYPE = new MYITEMTYPE()
            {
                ArchiveId = "4719",
                ICMBASE = new ICMBASE[] {
                    new ICMBASE(){
                        resourceObject = new LobObjectType()
                        {
                            label = new LobObjectTypeLabel()
                            {
                                name= resources0
                            },
                            MIMEType = resources1,
                            originalFileName = resources2
                        },
                    }
                }
            }
        },
    },
    mtomRef = new MTOMAttachment[] { new MTOMAttachment() {
        ID = resources0,
        MimeType = resources1,
        Value = System.IO.File.ReadAllBytes(resources2),  // Error on large files
    }},
};

var createReply = service.CreateItem(createRequest);
1

There are 1 answers

0
Alex AIT On BEST ANSWER

We "resolved" this by telling our customer to get a more potent system with more RAM. With 4-8GB of RAM we were able to upload files up to 200MB without problem.

Upon receiving large files, the Java-HeapSize in IBM Content Manager had to be increased. http://www.mkyong.com/websphere/how-to-increase-websphere-jvm-memory/