This article focuses on the technical aspects of the dynamic download formats by highlighting the involved backend and frontend utilities. The backend focuses on filtering and appending the asset storage items, based on the asset’s asset and MIME type. The frontend communicates with the backend via command handlers, to finally display the respective dynamic dialog formats in the dialogs, widgets, and wizards of the asset.

User Documentation

Backend

Class DynamicFormatData(censhare-Server/web-commands/com/api/download/DownloadUtil.java) checks the current asset’s asset type and MIME type against the asset type and MIME type filters provided to the dynamic download format resource asset. The dynamic download formats do not transform an asset in the following cases:

  • Its asset type and MIME type don’t match the filters of the dynamic download format resource asset
  • It has no storage items assigned to it

When the asset and MIME type filters apply to an asset, the dynamic download format file(s) are appended as storage item(s) into the asset XML.

Frontend

A promise in the censhare-Client5/web/src/ng1/framework/csApplication/cs-asset-unil.service.ts executes the com.censhare.api.dam.sharelink.dynamicFormatsHandler command handler to get the corresponding dynamic download formats from the backend. The addDynamicFormat method takes care to add the received dynamic download formats as asset files for the “Files” widget in the asset page and as checkbox option(s) in the “Create Shared Link” wizard and in “Download files” dialog.

promiseArr.push(this.csApiSession.execute('com.censhare.api.dam.sharelink.dynamicFormatsHandler', assetIDs: assetIDs }).then((dynamicFormatsInfo: any) => {
    ...
    addDynamicFormat(dynamicFormatsInfo.dynamic_formats.dynamic_format);
    ...
    }
}));
 
function addDynamicFormat(_dynamicFormatInfo) {
    if (_dynamicFormatInfo.asset) {
        dynamicFormats.push({
            key: _dynamicFormatInfo.key,
            supportedAssets: angular.isArray(_dynamicFormatInfo.asset) ? _dynamicFormatInfo.asset.m(_asset => _asset.id).join(',') : _dynamicFormatInfo.asset.id,
            label: _dynamicFormatInfo.label
        });
    }
}
// After all transformations were called, open the download dialog
return this.$q.all(promiseArr).then(function () {
    return {
        assets: assetsToDownload,
        storageItemsInfo: storageItemsGrouped,
        dynamicFormatsInfo: dynamicFormats
    };
});