M-Files API 23.11.13135.0
VaultObjectFileOperations Object
Members 
Description
A group of methods for creating and modifying object files.
Public Methods
Adds an empty file to an existing object.
Adds a new file to the specified object based on the given path.
Stops the specified file download.
Closes the upload session.
Converts the specified object file to PDF format.
Downloads the content of the specified file from the server to the specified path.
Downloads the content of the specified file as a data URI.
Downloads the content of the specified file as a data URI.
Downloads the content of the specified file from the server to the specified path.
Downloads the content of the specified file from the server to the specified path.
Downloads the content of the specified file from the server to the specified path.
Begins the block-by-block download of the specified file.
Begins the block-by-block download of the specified file (uses 32-bit arguments).
Begins the block-by-block download of the specified file (using 32-bit arguments).
Begins the block-by-block download of the specified file.
Begins the block-by-block download of the specified file (uses 32-bit arguments).
Begins the block-by-block download of the specified file (using 32-bit arguments).
Begins the block-by-block download of the specified file.
Begins the block-by-block download of the specified file.
Retrieves a specific block of the specified file from the server.
Retrieves a specific block of the specified file from the server (uses 32-bit arguments).
Searches the vault for duplicate emails based on the given message ID.
Locates the first 100 duplicates of a specified file version in the vault as a list of ObjIDs.
Searches the vault for duplicates of a file based on the given path as a list of ObjIDs.
Locates the first 100 duplicates of a specified obj version in the vault as a list of ObjIDs.
Uses a numerical digest to search the vault for file versions with a matching MD5 checksum.
Uses a string digest to search the vault for file versions with a matching MD5 checksum.
Finds all of the duplicates in the vault.
Gets all object files of the specified object.
Gets all object files of the specified object for modification in event handler.
Gets the size of the specified file.
Gets the size of the specified file.
Gets the size of the specified file (using 32-bit arguments).
Gets the size of the specified file.
Gets the latest version of the specified file.
Retrieves the object of the file.
Gets the path of the file in the ID view.
Gets the path to the file either in the ID view or a traditional folder.
Gets the path of the file in the ID view.
Gets the path to the file either in the ID view or in a traditional folder.
Gets the plain text content of a file in the vault.
Gets the plain text content of a file in the vault.
Gets the plain text content of a temporary file.
Checks if duplicates of a file exist.
Opens the given object file in the default application as specified.
Performs an optical character recognition operation for object file.
Deletes the specified file from the specified object.
Renames the given file.
Updates metadata embedded in the specified file.
Uploads the new content of the specified file to the server.
Uploads a block of the specified file.
Uploads a block of the specified file (uses 32-bit arguments).
Begins uploading a file to the server.
Begins uploading a file to the server (uses 32-bit arguments).
Commits the upload operation of the specified file.
Commits the upload operation of the specified file (uses 32-bit arguments).
Commits the upload operation of the specified file (using 32-bit arguments).
Commits the upload operation of the specified file.
Uploads the new content of the specified file to the server.
Uploads new content for the specified document file from the specified data URI.
Uploads new content for the specified document file from the specified data URI.
Uploads the specified file as a temporary file to the server.
Uploads a block of the specified temporary file.
Uploads a block of the specified temporary file (using 32-bit arguments).
Begins uploading a temporary file to the server.
Begins uploading a temporary file to the server (using 32-bit arguments).
Commits the upload operation of the specified temporary file.
Commits the upload operation of the specified temporary file (using 32-bit arguments).
Remarks
This method group interface can be accessed via the Vault object.
Example
' Initialize the API and connect to a vault.
Dim oVault As MFilesAPI.Vault
' ...

' We are searching for the document with ID 123.
Dim iDocumentId As Integer
iDocumentId = 123

' Initialize an ObjID object for the search.
Dim oObjId As New MFilesAPI.ObjID
oObjId.SetIDs(MFilesAPI.MFBuiltInObjectType.MFBuiltInObjectTypeDocument, iDocumentId)

' Invoke the search operation.
Dim oObjectVersion As MFilesAPI.ObjectVersion
Dim oObjectVersionAndProperties As MFilesAPI.ObjectVersionAndProperties
oObjectVersionAndProperties = oVault.ObjectOperations.GetLatestObjectVersionAndProperties(oObjId, True)
oObjectVersion = oObjectVersionAndProperties.VersionData

' Download all the files of the object.
Dim oObjectFiles As MFilesAPI.ObjectFiles = oObjectVersion.Files
For Each oObjectFile As MFilesAPI.ObjectFile In oObjectFiles
    ' Construct the target path for downloading the file.
    Dim szTargetPath = "C:\MyWorkFiles\" + oObjectFile.GetNameForFileSystem()
    ' Output the title and the extension of the object file.
    Call Console.WriteLine("Downloading '" + szTargetPath + "'")
    oVault.ObjectFileOperations.DownloadFile(oObjectFile.ID, oObjectFile.Version, szTargetPath)
Next

' Play around with the files here.
' ...

' Start uploading the files back to M-Files.
Dim oObjectVersionCheckedOut As MFilesAPI.ObjectVersion
' This object is not yet checked out for the current user, so try to check it out.
oObjectVersionCheckedOut = oVault.ObjectOperations.CheckOut(oObjId)

' Upload all the files of the object.
Dim oObjectFiles2 As MFilesAPI.ObjectFiles = oVault.ObjectFileOperations.GetFiles(oObjectVersionCheckedOut.ObjVer)
For Each oObjectFile As MFilesAPI.ObjectFile In oObjectFiles2
' Construct the source path for uploading the file.
    Dim szSourcePath = "C:\MyWorkFiles\" + oObjectFile.GetNameForFileSystem()
    ' Output the title and the extension of the object file.
    Call Console.WriteLine("Uploading '" + szSourcePath + "'")
    oVault.ObjectFileOperations.UploadFile(oObjectFile.ID, oObjectFile.Version, szSourcePath)
Next

' Finally, we must check in the changes.
oVault.ObjectOperations.CheckIn(oObjectVersionCheckedOut.ObjVer)

' Initialize the API and connect to a vault.
Dim oVault As MFilesAPI.Vault
' ...

' We are searching for the document with ID 123.
Dim iDocumentId As Integer
iDocumentId = 123

' Initialize an ObjID object for the search.
Dim oObjId As New MFilesAPI.ObjID
oObjId.SetIDs(MFilesAPI.MFBuiltInObjectType.MFBuiltInObjectTypeDocument, iDocumentId)

' Invoke the search operation.
Dim oObjectVersionCheckedOut As MFilesAPI.ObjectVersion
Dim oObjectVersionAndProperties As MFilesAPI.ObjectVersionAndProperties
oObjectVersionAndProperties = oVault.ObjectOperations.GetLatestObjectVersionAndProperties(oObjId, True)
oObjectVersionCheckedOut = oObjectVersionAndProperties.VersionData

' Get the info for all the versions of this document.
Dim oObjectVersions As MFilesAPI.ObjectVersions
oObjectVersions = oVault.ObjectOperations.GetHistory(oObjId)

' Check if this object version is checked out to the current user.
If oObjectVersionCheckedOut.ThisVersionCheckedOut Then
    Call Console.WriteLine("Document object: '" + oObjectVersionCheckedOut.GetNameForFileSystem() + "' [checked out to me]")
    Call Console.WriteLine("   Current version: " + CStr(oObjectVersionCheckedOut.ObjVer.Version))
    Call Console.WriteLine("   Checked out: " + oObjectVersionCheckedOut.CheckedOutAtUtc + " UTC")
    ' Try to resolve the previous version number before checkout.
    If oObjectVersions.Count > 1 Then
        Dim oObjectVersionOld As MFilesAPI.ObjectVersion = oObjectVersions.Item(oObjectVersions.Count - 1)
        Call Console.WriteLine("      Latest version before checkout identified by: " + CStr(oObjectVersionOld.ObjVer.Version))
    End If
Else
    Call Console.WriteLine("Document object: '" + oObjectVersionCheckedOut.GetNameForFileSystem() + "'")
End If

' Resolve the last modification timestamp of the object.
Dim dtObjectModification As Date = oObjectVersionCheckedOut.LastModifiedUtc
Call Console.WriteLine("   Object modified: " + CStr(dtObjectModification) + " UTC")

' Process the object files.
Dim oObjectFiles As MFilesAPI.ObjectFiles = oObjectVersionCheckedOut.Files
For Each oObjectFile As MFilesAPI.ObjectFile In oObjectFiles
    ' Construct the FileVer string for the file.
    Dim szFileVer = CStr(oObjectFile.ID) + "-" + CStr(oObjectFile.Version)
    ' Output the identification of the object file.
    Call Console.WriteLine("   Document file: '" + oObjectFile.GetNameForFileSystem() + "'")
    ' Resolve the last modification timestamp of the file content.
    Dim dtContentModification As Date = oObjectFile.LastAccessTimeUtc
    Call Console.WriteLine("      Currently identified by: " + szFileVer)
    ' Try to find the previous versions of the object files.
    If oObjectVersionCheckedOut.ThisVersionCheckedOut And oObjectVersions.Count > 1 Then
        Dim oObjectFilesOld As MFilesAPI.ObjectFiles = oObjectVersions.Item(oObjectVersions.Count - 1).Files
        For Each oObjectFileOld As MFilesAPI.ObjectFile In oObjectFilesOld
            If oObjectFileOld.ID = oObjectFile.ID Then
                ' Construct the FileVer string for the previous version of the file.
                Dim szFileVerOld = CStr(oObjectFileOld.ID) + "-" + CStr(oObjectFileOld.Version)
                Call Console.WriteLine("      Latest version before checkout identified by: " + szFileVerOld)
                Call Console.WriteLine("      File content modified: " + CStr(dtContentModification) + " UTC")
            End If
        Next
    End If
Next

See Also

VaultObjectFileOperations Members