Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

All files from Digizuite are served using the media pipelines. From DFS 9.0.0 the media pipeline has been redesigned, however, the old is still there for compatibility reasons.

It is configurable which one is used and this is controlled by a config parameter in DFS.Settings.config:

DFS.Settings.config
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>
		<setting name="DFS.MediaPipeline" value="dfsmedia"/>
	</settings>
  </sitecore>
</configuration>

There are two options

  • dfsmedia - the new implementation
  • media - the old implementation

The default valie is dfsmedia.

This section describes the new dfsmedia pipeline and its capabilities. For a description of the old media pipeline, see this link section 5.2.

Understanding the request

The new dfsmedia pipeline is accessible on the following endpoint: http(s)://<sitecore>/dfsmedia

The syntax of the url is: media/[SiloId]/[AssetId]-[Quality]/resize/[Width]x[Height]/compress/[0-100]/options/[Options]

And each parameter described:

Field

Description

SiloId

This is the Id of the silo that has the asset requested.

AssetId

Is the Id of the asset that is requested.

Quality

Overrides the quality specified in the Sitecore field.

Quality supports both 'by name' and 'by id'

Resize

Only applies to image assets.

One of the concepts and principles when using a DAM system is to use specific qualities for every use. If images are needed in different sizes, it should be configured in Digizuite™ DAM.

However, there is a resize feature.

Width How wide the image will be in pixels.

Height How high the image will be in pixels.

By default a resize does not keep aspect ratio, but you can set an option to keep aspect ratio.

Compress

Only applies to image assets.

Indicates whether the asset should be saved using a worse quality, thereby reducing the physical size. 

from 0-100 is allowed, where 0 is the worst quality, but least physical storage.

Options

Options is a dash ("-") separate list and can contain these options:

download - Will download the asset requested.

keepaspectratio - Will enforce aspect ratio on from the original asset, if a resize is requested.

upscaleallowed - Will allow upscaling an image. The default is to disallow that.

Compress - Reduces the quality of the image which decreases the size. 0-100 is allowed, where 100 is full quality and size. 

Understanding the DigizuiteMediaCache

The DigizuiteMediaCache is where everything, execpt videos, is saved. The cache location is configurable and is located in DFS.Settings.config

DFS.Settings.config
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>
	  <!-- Path to DAM For Sitecore MediaCache. The following is supported: 
             -UNC (\\server\example\cahcepath)
             -Full path (C:\example\cachepath)
             -Relative path (/App_Data/cachepath)      
      -->
      <setting name="DFS.CacheLocation" value="/App_Data/DigizuiteMediaCache"/>
	</settings>
  </sitecore>
</configuration>

The default location is in the website root under App_Data/DigizuiteMediaCache/.

Files are cached based on the request made to the asset. An example request could be: http(s)://<sitecore url>/dfsmedia/29a605d46a3340418c16542f7272c3ec/110-50035

According to the specification of the url, this request has the following properties:

  • AssetSiloId: 29a605d46a3340418c16542f7272c3ec 
  • AssetId: 110
  • FormatId: 50035

The cache is then build using a naming scheme. Each asset is placed in a sub-folder which has the name of the assetid. In the case of the example, the path in which the file is saved would be App_Data/DigizuiteMediaCache/110

The filename is then constructed based on the given properties using the following scheme:

{Assetid}_{formatid}_{width}_{height}_{options}.{extension}

where width, height and options are not used, if not requested (i.e. not used in the example), which means in the example, the requested asset would have the following name:

110_50035.{extention}

The extention is retrieved from the file saved in the cache. The naming scheme enable unique names and hence the extention can be extracted from the file in the cache. Orginally the file is saved with the correct extention based on what is served from the Digizuite.

UNC path

The dfsmedia pipeline also supports having a centralized cache, which means multiple servers can have the same cache. This decreases storage, but also performance, because files are then cached on a UNC which is slower than having it locally. This is something each client has to have an opinion on.

Implementation

The new dfsmedia pipeline is implemented as a httphandler, using a pipeline in Sitecore. This pipeline is located in the DFS.Services.config file:

Error rendering macro 'code': Invalid value specified for parameter 'firstline'
 <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
	<pipelines>     
	 <DFS.Services.DFSMedia>
        <processor type="DFS.Services.Pipelines.DFSMedia.CheckSecurity, DFS.Services" />        
        <processor type="DFS.Services.Pipelines.DFSMedia.GetMediaFromCache, DFS.Services" />
        <processor type="DFS.Services.Pipelines.DFSMedia.GetMediaPrerequisites, DFS.Services" />
        <processor type="DFS.Services.Pipelines.DFSMedia.GetMediaFromDigizuite, DFS.Services" />
        <processor type="DFS.Services.Pipelines.DFSMedia.ResizeImage, DFS.Services" />
        <processor type="DFS.Services.Pipelines.DFSMedia.SaveToCache, DFS.Services" />        
     </DFS.Services.DFSMedia>
    </pipelines>
  </sitecore>
</configuration>

Each step is explained as follows:

Pipeline nameDescription
DFS.Services.Pipelines.DFSMedia.CheckSecurity

This pipeline looks up the asset in the index using the context user.

If the user does not have access, the asset is not returned and the pipeline is stopped.

DFS.Services.Pipelines.DFSMedia.GetMediaFromCacheThis pipelines constructs a unique name based on the request and checks if the requested asset exists in the cache.
DFS.Services.Pipelines.DFSMedia.GetMediaPrerequisites

If the asset is not cached, it needs to be requested from Digizuite.

This pipeline gets all the prerequisites for requiring the asset in Digizuite

DFS.Services.Pipelines.DFSMedia.GetMediaFromDigizuiteThis pipeline executes the request towards Digizuite
DFS.Services.Pipelines.DFSMedia.ResizeImageIf a resize or #compres?? is requested, the bytes are processed here
DFS.Services.Pipelines.DFSMedia.SaveToCache

This pipeline saves the image to the cache

This pipeline may be modified according to customer needs. 

Hint

Outcommenting the security part of the pipeline increases performance of the cost of security, but for content delivery servers for public websites, this is typically not important and therefore it may be beneficial to outcomment this step. 

Extending the pipeline

If the pipeline is to be extended, for instance if some custom processing needs to be done to the image, then this may be done in between any of the steps above.

The pipeline step should have the following construction:

public class PipelineName : ProcessorBase<DFSMediaPipelineArgs>
{
	public override void Process(DFSMediaPipelineArgs args)
	{
		if (args.Result.StopPipeline)
        {
          return;
        }

        if (args.Request.Download)
        {
          return;
        }

        if (args.Result.Cached)
        {                       
          return;
        }
	    //code goes here
	}
}

Remember to include the custom step in the configuration file!

The object DFSMediaPipelineArgs contains a Request and a Result. These two objects has the following properties:

Request

ParameterTypeDescription
AssetSiloIdstringId of the asset silo from which the asset should be fetched
AssetIdstringId of the requested asset
FormatIdstringId of the format requested
DestinationIdstringDigizuite id of the destination - where to get the asset from
BaseUrlstringBaseUrl of the Digizuite
AccessKeystringAccessKey to the Digizuite
MimeTypestringMimetype of the requested asset
WidthstringIf a resize of the asset is requested, then this property contains the new width
HeightstringIf a resize of the asset is requested, then this property contains the new height
DownloadboolIf a download is requested, then this property is true
KeepAspectRatioboolif the aspect ratio should be kept, then this property is true
UpscaleAllowedboolif upscale is allowed, then this property is true
CompressstringIf the image should be compressed, then this has a value between 0 and 100

Result

ParametertypeDescription
ResultPathstringPath to the directory in which the asset is cached
FileNamestringName of the cached asset
CachedboolBoolean to indicate whether the asset is cached
ResultStreamTask<Stream>Handle for the result stream used to get the asset from Digizuite
ResizeBytesbyte[]If the image is resized and/or compressed, this array contains the result bytes
DownloadUrlstringRedirect url for download requests
StopPipelineboolIf the pipeline should be aborted, for instance due to security violation, then this is true
AssetAssetIndexableAsset model from the index
StatusCodeHttpStatusCodeStatus code used to indicate the request status.
  • No labels