Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 866
user1373140 Avatar asked Feb 19 '23 06:02

user1373140


1 Answers

Thanks for your responses. I was deleting the node but at the wrong place. I update the code like this and it works fine now.

 if (localComponent.IsMultimediaComponent)

                        {

                            XmlNode multimediaFileSizeNode = localComponentXML.SelectSingleNode("//*[local-name()='MultimediaFileSize']",tridionNamespace);

                            XmlNode dataNode = multimediaFileSizeNode.ParentNode;

                            dataNode.RemoveChild(multimediaFileSizeNode);

                        }



                        localComponent.UpdateXML(localComponentXML.InnerXml);
like image 161
user1373140 Avatar answered Mar 06 '23 18:03

user1373140