尝试上载大文件(100-500MB)时,我遇到了熟悉的“OutOfMemoryException”,这是由于尝试一次将整个文件读入内存(问及在这里回答stackoverflow)。我知道我应该使用流或将文件分成更小的部分。如果有帮助,手动更改代理代码是一个选项。我使用特定的web服务(CMWebService)。向IBM Content Manager WebService发送和接收大型MTOMA附件
由于我无法更改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);
耶,这个问题的代码帮助我解决了一个无关的问题:-) – 2015-12-10 21:05:52