向 IBM Content Manager Web Service 发送和接收大型 MTOMAttachments

本文关键字:大型 MTOMAttachments Content IBM Manager Web Service | 更新日期: 2023-09-27 18:32:51

当尝试上传大文件(100-500MB)时,我得到熟悉的"OutOfMemoryException",这是由于试图一次将整个文件读入内存(在stackoverflow上询问和回答)。我知道我应该使用流或将文件分成更小的部分。如果有帮助,手动更改代理代码是一种选择。我使用特定的网络服务(CMWebService)。

由于我无法更改 IBM 的代码,有没有办法将文件分成较小的部分发送?我已经找到了类 UpdateItemRequestAdd 和 UpdateItemRequestAddPart,但我无法让它们工作。不幸的是,IBM 也没有提供样本。

接收文件会带来同样的问题,我无法在那里找到任何可以帮助我的课程。

这是我当前用于上传文件的代码:

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);

向 IBM Content Manager Web Service 发送和接收大型 MTOMAttachments

我们通过告诉客户获得具有更多 RAM 的更强大的系统来"解决"这个问题。借助4-8GB的RAM,我们可以毫无问题地上传高达200MB的文件。

收到大文件后,必须增加 IBM Content Manager 中的 Java-HeapSize。http://www.mkyong.com/websphere/how-to-increase-websphere-jvm-memory/