I want to replace the jpg file of a multimedia component with a file with another extension (png for example). How can I check if the file extension is allowed for the component schema? I already got the MultimediaTypeData of the new extension:

string extension = "png";
var list = m_client.GetSystemWideList(new MultimediaTypesFilterData());
var multimediaType = list.OfType<MultimediaTypeData>().FirstOrDefault(mt => mt.FileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase));

With it, I can build LinkToMultimediaTypeData:

new LinkToMultimediaTypeData{ IdRef = multimediaType.Id };

1 Answer 1


Basically you need to use schema.AllowedMultimediaTypes property of the SchemaData object.

  1. Get the schema of the component you want to update and cast it to SchemaData object.
  2. Get allowed multimedia types for that schema using schema.AllowedMultimediaTypes.
  3. Put a condition to check if the new multimedia file is allowed, before updating the component.

Below is the example code:

            string componentToUpdateId = "tcm:7-5248";
            string mmExtensionIdToCheck = "tcm:0-1-65544";

            var item = client.Read(componentToUpdateId, new ReadOptions());
            var comp = item as ComponentData;
            var schema = client.Read(comp.Schema.IdRef, new ReadOptions()) as SchemaData;
            if (schema.AllowedMultimediaTypes.Any(t => t.IdRef == mmExtensionIdToCheck))
              // Update the component

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.