eDOCS DM API - 设置文件扩展名

时间:2017-09-21 23:18:31

标签: opentext

有点远,但我没有幸运地在任何地方找到答案。

我正在使用eDOCS DM API编写自定义工具,将文件批量上传到eDOCS。该工具几乎按预期工作,我创建了一个文件和元数据属性的任务列表,它创建了所需的eDOCS配置文件并保存文件。

将文件保存到eDOCS实质上是一个两步过程:

第1步 - 创建文档配置文件表单 这是通过创建具有键/值对的DM API对象来设置表单上的字段来完成的。 其中一个字段将文档链接到具有默认扩展名的特定应用程序(例如,MS Word,Excel等)。 创建配置文件后,eDOCS文件存储库中将生成一个空文件,其中包含随机文件名和链接应用程序的默认扩展名。

步骤2 - 将文档保存到存储库 这很简单,基本上将源文件读入字节数组,并使用eDOCS DM API对象将流写入eDOCS文件存储库中保存的文件(在步骤1中创建)。

我正在努力解决的问题是在创建表单时更改eDOCS文件存储库中生成的文件的扩展名。我还没有在官方文档或在线任何答案中找到任何指示(虽然我几年前在Spiceworks上发现有人问过这个问题(https://community.spiceworks.com/topic/196865-open-text-edocs-hummingbird-support-group?page=2#entry-5226944))。

所以一个实际示例rtf文件使用此工具保存到eDOCS并与Microsoft Word关联,因为Microsoft Word的默认扩展名设置为docx,文件以扩展名docx保存,当用户检索时Word无法解释文件并抛出错误信息。

使用标准的eDOCS DM扩展程序单独保存文件时,会有一个“另存为”文件。可用字段,允许您覆盖默认文件扩展名。

目前解决此问题的唯一方法是在eDOCS数据库应用程序表中为我们遇到的每个文件扩展名创建一个条目但是我希望有一种方法可以解决这个问题使用提供的API。

非常感谢任何建议,谢谢。

其他信息: 因此,我们在APP_FILE_EXTNS表中为每个应用程序定义了多个扩展,例如,我已经包含了下面与Microsoft Word相关的一些行:

APPS_LINK   LANGUAGE    EXTENSION   FILE_FORMAT DESCRIPTION         NEW_DOC_ONLY    ORDER_NO    DISABLED
1435        EN      docx        NULL        Word Document (*.docx)      N       1       N
1435        EN      DOT     NULL        Word 97-2003 Template (*.dot)   N       13      N
1435        EN      doc     NULL        Word 97-2003 Document (*.doc)   N       2       N
1435        EN      rtf     6       Rich Text Format (*.rtf)    N       8       N

以下是一个示例API调用(使用Powershell)来创建配置文件:

$doc = New-Object -ComObject PCDClient.PCDDocObject.1
$doc.SetDST($global:dmDST)
$doc.SetObjectType($global:dmForm)
$doc.SetProperty("PD_FILEPT_NO", $edocsFilePart)
$doc.SetProperty("DOCNAME", $docname)
$doc.SetProperty("APP_ID", $appid)
$doc.SetProperty("AUTHOR_ID", $author
$doc.SetProperty("TYPIST_ID", $typist
$doc.SetProperty("TYPE_ID", "DEFAULT")
$doc.SetProperty("%TARGET_LIBRARY", $global:dmLibrary)
$doc.Create()

# use PCDClient.PCDPutDoc and PCDClient.PCDPutStream to save the file to the edocs file repo
# unlock the document

因此,在上面的例子中,$ appid将与APPS表中的APPLICATION列相关(例如MS WORD,FOLDER,PDF等)。调用$ doc.Create()时会发生以下情况:

  • 创建了文档配置文件
  • 通过$ doc.SetProperty(" APP_ID",$ appid)创建edocs文件repo上的空文件,扩展名设置为应用程序集的默认扩展名。
  • COMPONENTS表已更新,以将空文件链接到文档配置文件

您是否知道是否有办法使用DM API将文件扩展名设置为与文档关联的应用程序的非默认扩展名之一?

我尝试过PCDClient.PCDDocObject.SetProperty(),其中包含几个不同的键,但都失败了:

  • EXTENSION
  • %EXTENSION
  • EXT
  • %EXT
  • PATH
  • %PATH
  • FILE_EXTENSION
  • %FILE_EXTENSION

2 个答案:

答案 0 :(得分:0)

我不确定这是否有帮助,但是我在设置扩展名的下面找到了此代码。

            Function ahtCommonFileOpenSave( _
            Optional ByRef flags As Variant, _
            Optional ByVal InitialDir As Variant, _
            Optional ByVal Filter As Variant, _
            Optional ByVal FilterIndex As Variant, _
            Optional ByVal DefaultExt As Variant, _
            Optional ByVal FileName As Variant, _
            Optional ByVal DialogTitle As Variant, _
            Optional ByVal hwnd As Variant, _
            Optional ByVal OpenFile As Variant) As Variant

                ' This is the entry point you'll use to call the common
                ' file open/save dialog. The parameters are listed
                ' below, and all are optional.
                '
                ' In:
                ' Flags: one or more of the ahtOFN_* constants, OR'd together.
                ' InitialDir: the directory in which to first look
                ' Filter: a set of file filters, set up by calling
                ' AddFilterItem. See examples.
                ' FilterIndex: 1-based integer indicating which filter
                ' set to use, by default (1 if unspecified)
                ' DefaultExt: Extension to use if the user doesn't enter one.
                ' Only useful on file saves.
                ' FileName: Default value for the file name text box.
                ' DialogTitle: Title for the dialog.
                ' hWnd: parent window handle
                ' OpenFile: Boolean(True=Open File/False=Save As)
                ' Out:
                ' Return Value: Either Null or the selected filename

                Dim OFN As tagOPENFILENAME
                Dim strFilename As String
                Dim strFileTitle As String
                Dim fResult As Boolean

                ' Give the dialog a caption title.
                If IsMissing(InitialDir) Then InitialDir = CurDir
                If IsMissing(Filter) Then Filter = ""
                If IsMissing(FilterIndex) Then FilterIndex = 1
                If IsMissing(flags) Then flags = 0&
                If IsMissing(DefaultExt) Then DefaultExt = ""
                If IsMissing(FileName) Then FileName = ""
                If IsMissing(DialogTitle) Then DialogTitle = ""
                If IsMissing(OpenFile) Then OpenFile = True

                ' Allocate string space for the returned strings.
                strFilename = Left(FileName & String(256, 0), 256)
                strFileTitle = String(256, 0)

                ' Set up the data structure before you call the function
                With OFN
                    .lStructSize = Len(OFN)
                    .hwndOwner = hwnd
                    .strFilter = Filter
                    .nFilterIndex = FilterIndex
                    .strFile = strFilename
                    .nMaxFile = Len(strFilename)
                    .strFileTitle = strFileTitle
                    .nMaxFileTitle = Len(strFileTitle)
                    .strTitle = DialogTitle
                    .flags = flags
                    .strDefExt = DefaultExt
                    .strInitialDir = InitialDir
                    ' Didn't think most people would want to deal with
                    ' these options.
                    .hInstance = 0
                    .strCustomFilter = ""
                    .nMaxCustFilter = 0
                    .lpfnHook = 0
                    'New for NT 4.0
                    .strCustomFilter = String(255, 0)
                    .nMaxCustFilter = 255
                End With

                ' This will pass the desired data structure to the
                ' Windows API, which will in turn it uses to display
                ' the Open/Save As Dialog.

                If OpenFile Then

                    fResult = aht_apiGetOpenFileName(OFN)

                Else

                    fResult = aht_apiGetSaveFileName(OFN)

                End If

                ' The function call filled in the strFileTitle member
                ' of the structure. You'll have to write special code
                ' to retrieve that if you're interested.

                If fResult Then
                    ' You might care to check the Flags member of the
                    ' structure to get information about the chosen file.
                    ' In this example, if you bothered to pass in a
                    ' value for Flags, we'll fill it in with the outgoing
                    ' Flags value.
                    If Not IsMissing(flags) Then
                        flags = OFN.flags
                    End If

                    ahtCommonFileOpenSave = TrimNull(OFN.strFile)

                Else

                    ahtCommonFileOpenSave = vbNullString

                End If

            End Function

答案 1 :(得分:-1)

简短的回答是您无法更改文件扩展名。

上传文件时,fileextension用于在配置文件中选择应用程序。在DM531 / DM10中,每个应用程序可以有一个默认扩展名(DOCX或DOC for word),然后您必须登录Cyber​​Docs才能添加其他文件扩展名。扩展名已添加到表APP_FILE_EXTNS中,请注意,由于eDOCS API生成了system_id,因此无法添加行。使用序列表SEQ_xxx创建system_id。应用程序位于APPS表中。

因此,您必须要求eDOCS DM管理员使用“库维护”或DM Management Studio工具(DM10或DM 16.x)添加所需的文件扩展名。

相关问题