/// <summary>
        ///     Gets the document stream for the specified entity identifier.
        /// </summary>
        /// <param name="entityId">The entity id.</param>
        /// <returns>The open file stream for the document stored in the file stream table.</returns>
        /// <remarks></remarks>
        private static RevisionData GetDocumentStreamForRevisionId(long entityId)
        {
            Stream stream = null;
            // Get the document revision
            var documentRevision = Entity.Get <DocumentRevision>(entityId);

            if (documentRevision == null)
            {
                EventLog.Application.WriteError("Unable to get the document revision stream, invalid document entityId {0}", entityId);
                return(null);
            }

            stream = FileRepositoryHelper.GetFileDataStreamForToken(Factory.DocumentFileRepository, documentRevision.FileDataHash);

            RevisionData result = new RevisionData
            {
                Stream        = stream,
                FileExtension = (documentRevision.FileExtension ?? "").ToLowerInvariant().Trim()
            };

            return(result);
        }
 /// <summary>
 ///     Gets the image data stream.
 /// </summary>
 /// <param name="imageFileDataHash">The image file data hash.</param>
 /// <returns></returns>
 public Stream GetImageDataStream(string imageFileDataHash)
 {
     return(FileRepositoryHelper.GetFileDataStreamForToken(Factory.BinaryFileRepository, imageFileDataHash));
 }