0

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 Answer 1

0

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

1
  • Perhaps convert this to VB.Net to make it even better as an answer for the VB.Net question Commented Jul 16, 2021 at 21:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.