File preview installation
The File Preview component enables preview of files in the web UI.
The File Preview component can be installed on the same server where ShareAspace Host and other ShareAspace components are installed but it is recommended to install any External Extension component on a separate machine if possible.
The File Preview component is optional to install and configure for a ShareAspace Collection. The file preview in the File Module and also file preview configured on views will only work if the File Preview component is installed and configured for that collection.
Prerequisites
The File Preview component server needs to apply to the following requirements:
- Hardware prerequisites for a File Preview Server (IIS)
- Software prerequisites for a File Preview Server (IIS)
Installation steps
Run the installer FilePreview.msi to install the File Preview component.
The default location of the installation will be at: C:\Program Files\Eurostep\ShareAspace\FilePreview.
When the File Preview component is installed a new Application Pool is created with the name
FilePreview that will be used by the new FilePreview Application in the IIS.
Configuration
The file appsettings.json in the installation folder of the File Preview component
is the settings file for the component. The File Preview component requires a symmetric key that
is used to ensure secure communication. The symmetric key is configured with the setting
SymmetricKey in the NovaConfig section.
The SymmetricKey key should be generated as described in the section
Generate Symmetric Signing Keys.
"NovaConfig": {
"SymmetricKey": "uYXVvyCDKqD80UUJwy1LJC0mIps00qBC84w9sBtK/crY2bXlu3xV9oBI7i+5sS9LFBAR6iKjfJF1edKopwhnEQ=="
}
It is possible to restrict the hosts that can connect to the File Preview component using
the setting AllowedHosts. The default value is set to * i.e. any host. Sub domain wildcards are
permitted e.g. "*.example.com" matches sub-domains like foo.example.com, but not the parent domain
example.com.
The ShareAspace collection that will use the File Preview component has to configure an Nova Extension before it can be used by that collection.
Note
The File Preview component must be up and running during the registration process since a manifest exchange is being made between ShareAspace and the extension.
Add file preview extension with script
It is possible to set up the External Extension needed for the File Preview component with a PowerShell script.
Download add-file-preview-extension.ps1
function getAuthorizationHeader ($key, $path){
$encodedPath = [Text.Encoding]::ASCII.GetBytes($path)
$sha = New-Object System.Security.Cryptography.HMACSHA512
$sha.key = [Convert]::FromBase64String($key)
$hash = $sha.ComputeHash($encodedPath)
$hashString = [Convert]::ToBase64String($hash)
$bearerToken = $hashString.Split('=')[0]
$bearerToken = $bearerToken.Replace('+', '-')
$bearerToken = $bearerToken.Replace('/', '_')
return @{"Authorization" = ("Bearer", $bearerToken -join " ")}
}
function addExternalExtension($adminKey, $externalExtensionKey, $externalExtensionUri) {
$path = "/admin/novaExtension";
$uri = "http://localhost:5000" + $path
$headers = getAuthorizationHeader $adminKey $path
$body = @{
tokenLifeTime = 15
active = $true
apiKey = $externalExtensionKey
hostUri = $externalExtensionUri
} | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri $uri -ContentType "application/json" -Headers $headers -Body $body
}
$adminKey = "admin-sym-key"
$filePreviewKey = "file-preview-sym-key"
$filePreviewUri = "https://my.filepreview.machine.net/FilePreview"
addExternalExtension $adminKey $filePreviewKey $filePreviewUri
IIS settings
When installing the ShareAspace File Preview, an Application Pool named "FilePreview" is created in IIS. By default the account running the Application Pool is the built-in account "LocalSystem".
Note
If another account has to be used for running the "FilePreview" Application Pool, the account running the "FilePreview" Application Pool must have read access to the File Preview installation folder.
Additional installed components
The process of creating document previews is separated into two components, these are pipelined together to produce a number of images, one for each page or slide of a document:
- LibreOffice component
- MuPdf
If a document is of type PDF, XPS or EPUB the MuPdf component converts directly to preview images. Other types of office documents will first be processed through LibreOffice where it is converted to PDF then sent to MuPdf for final processing of converting to preview images.
Note
There is a limit to the number of pages from a document that can be previewed. Long documents may hit this limit.