I'm having some difficulties understanding how the MTOM functionality of the UploadContent method in the ContentService works(this is the EWS). I've tried the following code:try
{
openFileDialog1.Multiselect = false;
openFileDialog1.Title = "Upload document";
openFileDialog1.ShowDialog(this);
FileInfo file = new FileInfo(openFileDialog1.FileName);
int parentID = 2000;
string comment = "Uploadtest of document with contentservice";
bool advancedVersion = true;
DocumentService.Metadata metadata = null;
string docContext = documentClient.CreateDocumentContext(documentAuth, parentID, file.Name, comment, advancedVersion, metadata);
FileAtts atts = new FileAtts();
atts.CreatedDate = file.CreationTime;
atts.FileName = file.Name;
atts.FileSize = file.Length;
atts.ModifiedDate = DateTime.Now;
FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read);
MemoryStream ms = null;
byte[] bytes = null;
int length = 3072;
int offset = 0;
string objectID = "";
while (fs.Position < fs.Length)
{
if ((fs.Length - fs.Position) < length)
{
length = Convert.ToInt32((fs.Length - fs.Position));
}
bytes = new byte[length];
fs.Read(bytes, 0, length);
ms = new MemoryStream(bytes);
objectID = contentClient.UploadContent(contentAuth, docContext, atts, ms);
offset += length;
}
StatusLbl.Text = "Uploaded document ID = " + objectID;
Node test = documentClient.GetNode(documentAuth, Convert.ToInt32(objectID));
}
catch (Exception ex)
{
StatusLbl.Text = ex.Message;
}
When the while-loop iterates for the second time i get the following error-message: "An item with the name {filename} already exists. I've never used MTOM before, but from what i've read, this seems to be the way to upload large files. Anyone have any advice or codeexamples which shows how to utilize the MTOM functionality of the LL EWS?