在VB.NET中上传FileNet文件

问题描述

我正在尝试将文件上传到特定的FileNet文件夹,此代码仅创建一个空的pdf文档。有帮助吗?

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)

解决方法

您需要将内容元素添加到您的文档中。

C# 示例:

// 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);
}

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

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...