Friday 3 March 2017

Uploading images from SDL Web (Tridion) to SDL Media Manager

Consider the scenario where you need to migrate all the images from your SDL Web CMS to SDL Media Manager. For each image in SDL Web, the solution would involve:
  • Downloading the image
  • Uploading the image to SDL Media Manager
  • Creating a program and distribution in SDL Media Manager
  • Putting the distribution Live
  • Finding the "using components" in SDL Web and updating each one by replacing the relationship to the image in SDL Web with the relationship to the equivalent image in SDL Media Manager.
To complete all the steps above, you will require the following.
  • SDL Web Core Service client
  • SDL Web Stream Download client
  • SDL Media Manager client
  • ECL Service client
Here are the supporting app settings.


As shown above, the first set of properties is related to the SDL Web (Tridion) Core Service. The second set of properties is related to Media Manager, which includes the IssuerName specifying the URL to the Secure Token Service (STS). The third set of properties is required for specifying:
  • A spreadsheet mapping the SDL Web (Tridion) folder structures to the equivalent folder structures in Media Manager.
  • A directory used for storing the images downloaded from SDL Web for uploading to Media Manager.
  • The tcmid of the schema (asset type) to be migrated. In the listing above, the tcm:5-33-8 corresponds to the Image multimedia schema.
  • The name of the asset type (as defined in Media Manager) to be migrated.
  • The named of the outlet (as defined in Media Manager) to be used when creating the distributions in Media Manager.
  • The name of the tag (as defined in Media Manager) to be used when uploading and creating the assets in Media Manager.
The Media Manager Secure Token Service is essential for running the asset migration. It allows the communication to Media Manager to be established through the API. In the application settings above, the STS service is available from the http://localhost:89/IWSTrust13/ URL.

The Media Manager API does not support the creation of folders. Therefore, before migration can take place, the folder structures in SDL Web must be replicated in Media Manager to accommodate the assets. The TridionToMediaManagerFolderMappingsFile configuration property specifies a spreadsheet containing the full mappings between the existing folder structures in SDL Web and the equivalent folders created in SDL Media Manager.

Downloading assets from SDL Web (Tridion)


The code for downloading assets from SDL Web is shown below.


Uploading to SDL Media Manager


The code for uploading to SDL Media Manager is shown below. This code also creates the program, the distribution and puts the distribution live.


Updating the relationships in SDL Web (Tridion)


The download and upload steps complete the process of migrating assets from SDL Web to SDL Media Manager. However, it is also important to update the components using the migrated asset by swapping the reference for the new asset in SDL Media Manager.

This step relies on a SessionAwareEclServiceClient only available through a netTcpBinding which is not exposed. Therefore, a solution invoking this service can only run on the CME server itself.

And through the following endpoint.

You will need to copy the Tridion.ExternalContentLibrary.Service.Client.dll file from the SDL Web CME server and import into your solution in order to build the project.

The code below takes the core service and ECL clients, the migrated SDL Web multimedia component and a Dictionary object containing information gathered during the upload process. This information includes the distribution id, which is used to create or get the stub to the asset originating from Media Manager.

1 comment:

  1. Very informative and It was an awesome post. I love reading your fantastic content. Thanks for sharing it with us. We are so greatful to your sharing. Download Razorsql

    ReplyDelete