Document File Manager (.NET)

The Document File Manager API exposes methods for downloading native, image, and produced image files associated with documents in Relativity. You can download a file by specifying its GUID, or you can download a native file by specifying the Artifact ID of the document associated with it. The Document File Manager API also supports retrieving information about these files, such as GUID, name, type, size, and others.

Sample use cases for the Document File Manager API include the implementing the following functionality:

  • A custom agent that downloads native audio files, transcribes them, and writes the text back to Relativity.
  • A custom page that displays the names, sizes, and types for a subset of documents.

You can also use the Document File Manager service through the REST API. For more information, see Document File Manager (REST).

This page contains the following information:

Fundamentals for the Document File Manager API

The Document File Manager API contains the following methods, classes, and enumerations.

Methods

The Document File Manager API exposes the following methods on the IDocumentFileManager interface in the Relativity.Services.Interfaces.Document namespace:

  • DownloadFileAsync() method - downloads a native, image, or produced image file based on the specified GUID. Its parameters include the Artifact ID of a workspace containing the document, and the GUID for the file to download. It returns a stream containing the file. See Download a file by GUID.
  • DownloadNativeFileAsync() method - downloads a native file by specifying the Artifact ID of the Document object associated with it. Its parameters include the Artifact IDs of a workspace and Document object. It returns a stream containing the file. See Download a native file by Document Artifact ID.
  • GetFileInfoAsync() method - retrieves information about the files associated with a document in Relativity. Its parameters include the Artifact IDs of a workspace and Document object. This method returns a list of DocumentFile objects. See Retrieve document file information.

Classes and enumerations

The Document File Manager API includes the following class and enumerations available in the Relativity.Services.Interfaces.Document.Models namespace:

  • DocumentFile class - represents information about a native, image, or produced image file. Its properties include GUID, name, type, size, and others. The GetFileInfoAsync() method returns an object of this type. See the DocumentFile class in the Services API.
  • DocumentFileRotation enumeration - indicates the rotation of a file. Valid values include:
    • NotSet
    • ZeroDegrees
    • NinetyDegrees
    • OneHundredEightyDegrees
    • TwoHundredSeventyDegrees
  • DocumentFileType enumeration - indicates the type of the file. Valid values include Native, OriginalImage, and ProducedImage.

For more information, see the Relativity.Services.Interfaces.Document.Models namespace in the Services API.

Retrieve document file information

You can retrieve information about the files associated with a document, including the file name, GUID, page orientation and other properties.

Note: To retrieve the file information for a document, you must have rights to view it in the workspace. Additionally, you must have access rights to view a production for its associated files to be included in the results.

The following code sample illustrates how to pass the Artifact IDs of a workspace and Document object to the GetFileInfoAsync(). The method returns a list of DocumentFile objects, and the total count is written to the console.

public static async Task GetFileInfo()
 {
    int workspaceArtifactID = 1016883;
    int documentArtifactID = 1038018;
    ServiceFactory factory = Helper.GetServiceFactory();
    using (IDocumentFileManager documentFileManager = factory.CreateProxy<IDocumentFileManager>())
    {
        List<DocumentFile> documentFiles = await documentFileManager.GetFileInfoAsync(workspaceArtifactID, documentArtifactID);
        Console.WriteLine(documentFiles.Count);
    }
}

Download files

You can download native, image, and produced image files associated with documents in Relativity.

The response contains these properties with the following settings for HTTP headers:

  • ContentType - the extension of the file determines the value of this header.
  • ContentDisposition - the name of the file as defined within Relativity determines the filename in attachment; filename=. See Download a file by GUID

Note: For native and image files, you must have rights to the document in the workspace. For produced image files, you must have rights to both the document and the production that includes the produced images.

Download a file by GUID

You can download a native, image, or produced image file by specifying its GUID in a call to the DownloadFileAsync() method. To obtain the GUID of a file for download, use the GetFileInfoAsync() method. See Retrieve document file information.

The following code sample illustrates how to pass the Artifact ID of a workspace and a GUID for a file to the DownloadFileAsync() method. This method returns a stream containing the file. It saves the file to disk using the file name specified in the ContentDisposition header.

public static async Task DownloadFile()
{
    int workspaceArtifactID = 1016883;
    Guid fileGuid = new System.Guid("d6d94ed0-c46b-427d-b702-2682f1e43cf5");
    ServiceFactory factory = Helper.GetServiceFactory();
    using (IDocumentFileManager documentFileManager = factory.CreateProxy<IDocumentFileManager>())
    using (IKeplerStream keplerStream = await documentFileManager.DownloadFileAsync(workspaceArtifactID, fileGuid))
    {
        System.Net.Http.Headers.ContentDispositionHeaderValue headerValue = System.Net.Http.Headers.ContentDispositionHeaderValue.Parse(keplerStream.ContentDisposition);
        string fileName = headerValue.FileName.Replace("\"", "");
        string fileDestination = @"C:\RelativityDocuments\" + fileName;
        using (Stream fileStream = await keplerStream.GetStreamAsync())
        using (Stream destinationStream = File.Create(fileDestination))
        {
            await fileStream.CopyToAsync(destinationStream);
        }
    }
}

Download a native file by Document Artifact ID

You can download a native file by making a call to the DownloadNativeFileAsync() method and specifying the Artifact ID of the document associated with it. This convenience method functions similarly to calling the DownloadFile endpoint with the GUID for a native file, except that you specify the Artifact ID of a Document object.

The following code sample illustrates how to pass the Artifact IDs of a workspace and Document object to the DownloadNativeFileAsync() method. This method returns a stream containing the native file and saves it to disk.

public static async Task DownloadNativeFile()
{
            int workspaceArtifactID = 1016883;
            int documentArtifactID = 1037999;
            string fileDestination = @"C:\RelativityDocuments\mynativefile" + documentArtifactID;
            ServiceFactory factory = Helper.GetServiceFactory();
            using (IDocumentFileManager documentFileManager = factory.CreateProxy<IDocumentFileManager>())
            using (IKeplerStream keplerStream = await documentFileManager.DownloadNativeFileAsync(workspaceArtifactID, documentArtifactID))
            using (Stream fileStream = await keplerStream.GetStreamAsync())
            using (Stream destinationStream = File.Create(fileDestination))
            {
                await fileStream.CopyToAsync(destinationStream);
            }
        }

Community Updates

Aero Developer FAQ Evolving the Platform Most recent release notes
Learn more Learn more Learn more

Additional Resources

   
Access Third-Party Tools with GitHub     Create .NET Apps Faster with NuGet
Visit github     visit nuget