Search code examples
componentstridionupdatesmultimedia

Updating multimedia component using TOM.NET


I am trying to update the metadata on the multimedia image in C# using Tridion's TOM.NET API like this

 componentMM.LoadXML(localComponent.GetXML(XMLReadFilter.XMLReadALL));
 // make changes to the component mm multimedia text;
 localComponent.UpdateXML(componentMM.InnerXML);
 localComponent.Save(True)

While this works for other components, it is failing for Multimedia images.

<?xml version="1.0"?>
<tcm:Error xmlns:tcm="http://www.tridion.com/ContentManager/5.0" 
           ErrorCode="80040345" Category="19" Source="Kernel" Severity="2">
    <tcm:Line ErrorCode="80040345" Cause="false" MessageID="16137"><![CDATA[ 

    Unable to save Component (tcm:33-32599).
    ]]><tcm:Token>RESID_4574</tcm:Token>
        <tcm:Token>RESID_4418</tcm:Token>
        <tcm:Token>tcm:33-32599</tcm:Token>
    </tcm:Line>
    <tcm:Line ErrorCode="80040345" Cause="true" MessageID="15747"><![CDATA[ 

    Unexpected element: MultimediaFileSize
    ]]><tcm:Token>MultimediaFileSize</tcm:Token>
    </tcm:Line>
    <tcm:Details>
        <tcm:CallStack>
            <tcm:Location>ComponentBL.CheckMultiMediaProperties</tcm:Location>
            <tcm:Location>ComponentBL.CheckMultiMediaProperties</tcm:Location>
            <tcm:Location>ComponentBL.Update</tcm:Location>
            <tcm:Location>XMLState.Save</tcm:Location>
            <tcm:Location>Component.Save</tcm:Location>
        </tcm:CallStack>
    </tcm:Details>
</tcm:Error>

Can you please let me know what am I doing wrong here?


Solution

  • Include only the tcm:Metadata node in your update?

    Specifically, it is complaining about you specifying the size of the mm file, which you shouldn't, that's a system property. Clean up the XML you receive from Tridion to remove that property (it might then complain about another property, just do what it asks you to).

    EDIT: Reading the error messages is a great skill to have...