/
Media Services

Media Services

The media services consist of services which allows retrieving images and files, collectively called Binaries, out of Perfion. The Media Services API is hosted on a Microsoft IIS Web Server. The services are designed according to a pull-strategy such that it scales linearly.

The media services consist of the following services:

 Service name

Description

File

Binary file service. Serves Perfion file and image type binaries, but does not allow any image processing. The service will only deliver the original file content and it has an option to either show file content in line (e.g. in internet browser) or define it as an attachment which will force users to download the file instead of rendering file content inline.

Any requested files will be saved in a cache and the service will use the cached file next time the same request is sent.

Image

Binary image service. Serves Perfion file and image type binaries and allows image processing. Image processing is possible only when using Perfion image type binaries. The image service will serve Perfion file type binaries, but such binaries will be served as if they were requested via the File service. This means that image processing is not supported for such requests.

The service has an option to either show file content inline (e.g. in a browser) or stream the content as an attachment available for download.

Any processed images will be saved in a cache and the service will use the cached file next time the same request is sent.

The image service can optionally add watermark to the images based on configuration and the request parameters. Please refer to the Image Watermarking section for more details.

Watermarked Image

The Watermarked Image service works similar to the Image service, with the exception that it adds watermark to all served images and that it only will serve image type binaries. As file type binaries cannot have watermarks applied to them, the Watermarked service will not service such requests.

UncachedImage

The Uncached Image service works similar to the Image service with the exception that it will not use any precached renditions.

NOTE: The ability for a file or an image content to be rendered inline depends on the ability of the application which renders the response from media services. In most cases such application will be an internet browser. Most internet browsers can render images inline. An exception could be that it will not render more complicated image formats such as TIFF. Most internet browsers will also render some of the file formats inline, e.g. if it is a text, HTML or XML file.

Media Service Configuration

Media services have several parameters which may be set to change its behavior. The configuration parameters can be specified in several ways:

  • Web.Config file. The “appSettings” element of the Web.Config file is used to add media services parameters and “connectionStrings” element is used when defining connection string to Perfion database.

  • MediaService.Config file. This configuration file is optional, but if defined, then all media services parameters will be used from this file instead of using Web.Config file.

NOTE: The use of Web.Config file to specify media services parameters is used for backwards compatibility to support previous versions of media services. It is recommended to use MediaService.Config file instead.

The table below shows all parameters supported by media services. Note that all parameter names are based on how they are defined in MediaService.Config file. The equivalent parameter names are also provided for Web.Config file in parameter descriptions.

Parameter name

Description

ID

Media service ID. The parameter is optional for database based media service and required for Perfion Cloud based media service.

The ID is a standard GUID identifier, e.g. ‘8e118ad2-70eb-430f-8cd0-ca9a8408f897’.

Parameter key in Web.Config file: Perfion.MediaServiceId

Name

Media services name.

Optional parameter. Used only with Perfion Cloud based media service.

Parameter key in Web.Config file: Perfion.MediaServiceName

IsActive

Boolean parameter which defines if the media service is enabled.

Parameter key in Web.Config file: Perfion.IsActive. It is optional for Web.Config and if not define will have a default value ‘true’, e.g. the media service is enabled.

PerfionDBConnectionString

Connection string of Perfion database. Used only with database based media services.

Note that connection string should be blank when using Perfion Cloud based media services.

Parameter name in Web.Config file: connectionStrings ->add element with a name ”perfionConn” e.g.:

StorageServiceUrl

Perfion Storage Service URL. Parameter is optional and used only when media service should serve binaries from the Perfion Cloud by using Storage Service.

Note that this parameter will only be used if PerfionDBConnectionString is not defined.

Parameter key in Web.Config file: Perfion.StorageServiceUrl

StorageServiceKey

Perfion Storage Service API Key. Parameter is optional and used only when media service should serve binaries from the Perfion Cloud by using Storage Service.

Note that this parameter will only be used if PerfionDBConnectionString is not defined.

Parameter key in Web.Config file: Perfion.StorageServiceKey

WatermarkRange

Image watermark related parameter which defined how the watermark image must be applied.

It is an integer number. Values:

  • 0 (default) – watermark image is disabled and will not be applied.

  • 1 – watermark image is enabled and will be applied regardless of how big the target image is.

  • larger than 1 – watermark image will be applied only if the resulting image dimension on either side is larger than watermark range value. The value is defined in pixels.

The parameter is optional.

Parameter key in Web.Config file: Perfion.WatermarkRange

WatermarkPath

Defines the path to the image that should be used as watermark. Note that the path is relative to the image service (e.g. Image.aspx) file.

The parameter is optional.

Please note that if WatermarkPath it is not defined or is invalid, watermarks will not be applied to images served by the Image- and UncachedImage service.
The Watermarked Image service will reject any requests if WatermarkPath is not defined or is invalid.

Parameter key in Web.Config file: Perfion.Watermark

NoImageImagePath

The path to an image which will be used when there is no image to show, e.g. when image ID used in request is not found.

The parameter is optional and if not defined, the image services will use a default image.

The path is relative to the image service (e.g. Image.aspx) file.

Parameter key in Web.Config file: Perfion.NoImageFoundImage

HttpCacheability

The parameter allows to control Cache-Control HTTP header for media services response. Values correspond to .NET HttpCacheability supported values:

  • Server (default). Specifies that the response is cached only at the origin server.

  • NoCache. Sets the Cache-Control: no-cache header.

  • Private. Sets Cache-Control: private to specify that the response is cacheable only on the client and not by shared (proxy server) caches.

  • Public. Sets Cache-Control: public to specify that the response is cacheable by clients and shared (proxy) caches.

  • ServerAndNoCache. Applies the settings of both Server and NoCache to indicate that the content is cached at the server but all others are explicitly denied the ability to cache the response.

  • ServerAndPrivate. Indicates that the response is cached at the server and at the client but nowhere else. Proxy servers are not allowed to cache the response.

The parameter is optional. If not define will use “Server” value.

For more information refer to Microsoft .NET documentation: HttpCacheability Enum (System.Web)

Parameter key in Web.Config file: Perfion.FileHttpCacheability

ReadTimeoutInMs

The parameter is used with media cache files which are stored locally in the server file system to determine how long the request should wait while trying to read the cache file if it is occupied by other processes (e.g. because other request are handling the file).

The parameter is used only with database media services.

Optional parameter. The default value is 5000 milliseconds.

Parameter key in Web.Config file: Perfion.BinaryCache_ReaderTimeOut

WriteTimeoutInMs

The parameter is used with media cache files which are stored locally in the server file system to determine how long the request should wait while trying to write (e.g. create/update) the cache file if it is occupied by other processes (e.g. because other request are handling the file).

The parameter is used only with database media services.

Optional parameter. The default value is 5000 milliseconds.

Parameter key in Web.Config file: Perfion.BinaryCache_WriteTimeOut

MinimumDiskSpaceInMb

The parameter allows to specify the limit of the disk space which is considered as critically low for media service to operate. If server disk space becomes lower than this parameter defines, the media service will show an error about too low disk space.

The media services can generate large cache files in local disc and if there is not enough space, the media service will fail. The use of this parameter prevents such failure and allows identifying the real problem earlier before the whole server could stop responding or crash.

Optional parameter. The default value is 100 MB.

The parameter is used only with database based media services.

Parameter key in Web.Config file: Perfion.DiskSpaceLimitInMb

CacheRecheckDelayInMs

The parameter defines HTTP caching header expiration time.

Optional parameter. The default value is 300000 milliseconds (5 minutes).

Parameter key in Web.Config file: Perfion.BinaryCache_CachingTime

CacheRelativePath

The parameter defines the location where media services cache and log files will be located.

Optional parameter. The Default value is “Cache”.

The parameter is used only with database based media services.

Parameter key in Web.Config file: Perfion.CacheStoragePath

LogLevel

The parameter defines the logging level. Media services if fails will write log data and this parameter determines how detailed this data should be. Values:

  • Error. The log record will be created only when the request to media serv