I am able to successfully send a file to Filenet using their API (FileNet.API.dll) v5.2.1 but when I try to retreive it, it is a 0 byte file with no content.
This is essentially using the methods found in their demo c# program that sends and receives files found here (http://www-01.ibm.com/support/docview.wss?uid=swg24028791)
The difference with my scenario is that I will have the source data already in Stream form so I don't to need convert a local file to a Stream like the demo does.
So the Following Methods are run: more or less in this order, some are repeated.
main create doc method executes
IDocument doc = CreateDocument(stream, fnDoc.mimeType, fnDoc.docName, fnRepo.os, "Common", paRequest);
IFolder folder = FetchFolder(fnRepo.os, "/");
doc.Save(RefreshMode.REFRESH);
IReferentialContainmentRelationship rcr = FileContainable(fnRepo.os, doc, folder);
rcr.Save(RefreshMode.REFRESH);
checkInDoc(doc);
The methods listed above are below
public static IDocument CreateDocument(Stream stream, String mimeType, String docName, IObjectStore os, String className)
{
IDocument doc = null;
if (className.Equals(""))
doc = Factory.Document.CreateInstance(os, null);
else
doc = Factory.Document.CreateInstance(os, className);
doc.Properties["DocumentTitle"] = docName;
doc.MimeType = mimeType;
IContentElementList cel = CreateContentElementList(stream, docName);
if (cel != null)
doc.ContentElements = cel;
return doc;
}
next one that is called is CreateContentElementList
public static IContentElementList CreateContentElementList(Stream stream, string docName)
{
IContentElementList cel = null;
if (CreateContentTransfer(stream, docName) != null)
{
cel = Factory.ContentElement.CreateList();
IContentTransfer ct = CreateContentTransfer(stream, docName);
cel.Add(ct);
}
return cel;
}
Then finally CreateContentTransfer
public static IContentTransfer CreateContentTransfer(Stream stream, string docName)
{
IContentTransfer ct = null;
ct = Factory.ContentTransfer.CreateInstance();
ct.SetCaptureSource(stream);
ct.RetrievalName = docName;
return ct;
}
At this point the length and size of ct is not there but these can be set manually so I am not sure if that matters. Also the variable stream still has content.
The doc is returned from CreateDocument
Then folder is fetched
public static IFolder FetchFolder(IObjectStore os, String fPath)
{
IFolder f = Factory.Folder.FetchInstance(os, fPath, null);
return f
}
then
public static IReferentialContainmentRelationship FileContainable(IObjectStore os, IContainable c, IFolder folder)
{
IReferentialContainmentRelationship rcr = null;
if (c is IDocument)
rcr = folder.File((IDocument)c, AutoUniqueName.AUTO_UNIQUE, ((IDocument)c).Name, DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE);
else
rcr = folder.File((ICustomObject)c, AutoUniqueName.AUTO_UNIQUE, ((ICustomObject)c).Name, DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE);
return rcr;
}
public static void checkInDoc(IDocument doc)
{
doc.Checkin(AutoClassify.AUTO_CLASSIFY, CheckinType.MINOR_VERSION);
doc.Save(RefreshMode.REFRESH);
doc.Refresh();
}
So am I missing something, some last part to actually put the content on the server or something?