FileNet file upload in VB.NET

412 views Asked by At

I'm trying to upload a file to a specific FileNet folder, this code only creates an empty pdf document. Any help?

Dim folder As IFolder = Factory.Folder.GetInstance(os, ClassNames.FOLDER, New Id(IdS))
Dim doc As IDocument = Factory.Document.CreateInstance(os, ClassNames.DOCUMENT, Nothing)
doc.Properties("DocumentTitle") = "Test110"
doc.MimeType = "application/pdf"
doc.Save(RefreshMode.NO_REFRESH)
Dim rcr As IReferentialContainmentRelationship = folder.File(doc, AutoUniqueName.AUTO_UNIQUE, "Test", DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE)
rcr.Save(RefreshMode.NO_REFRESH)
1

There are 1 answers

1
Gerald McCartney On

You need to add Content Element(s) to your Document.

C# example:

// Specify internal and external files to be added as content.
Stream internalFile = File.OpenRead(@"C:\\BootstrapConfigUtility.bat");
String externalFile = "file://C:\\BootstrapConfigUtility.bat";

// Add content to the Reservation object.
try {
    // First, add a ContentTransfer object.
    IContentTransfer ctObject = Factory.ContentTransfer.CreateInstance();
    IContentElementList contentList = Factory.ContentTransfer.CreateList();
    ctObject.SetCaptureSource(internalFile);
    // Add ContentTransfer object to list.
    contentList.Add(ctObject);

    // Second, add a ContentReference object.
    IContentReference crObject = Factory.ContentReference.CreateInstance(os);
    crObject.ContentLocation = externalFile;
    crObject.ContentType = "text/plain";// Must be set for ContentReference.
    // Add ContentReference object to list.
    contentList.Add(crObject);

    doc.ContentElements = contentList;
    doc.Save(RefreshMode.REFRESH);
}
catch (Exception e)
{
    System.Console.WriteLine(e.Message);
}

see: https://www.ibm.com/docs/en/filenet-p8-platform/5.2.0?topic=documents-working#document_procedures__doc_procedures_create