The following code loads a source asset and the asset to replace. It then branches the later and replaces the branch with the source asset.
<%
Asset sourceAsset = Asset.Load("/path/to/source/asset.jpg");
Asset replaceAsset = Asset.Load("/path/to/asset/to/replace.jpg");
Asset aBranchedFile = Asset.CreateBranch(replaceAsset);
if (aBranchedFile.IsLoaded)
{
Out.WriteLine("ID: " + aBranchedFile.Id.ToString());
string base64data = BinaryFile.LoadAsBase64(sourceAsset.Id.ToString());
if(!aBranchedFile.UpdateFromBase64(base64data))
Out.WriteLine("context: " + context.Error);
}
%>
--
Edward ChanSr Product Consultant
## If I’ve helped, accept this response as a solution so that other’s can find is more quickly in the future.
## Have thoughts on Crownpeak products? We'd love to hear them. Speak with the Crownpeak Product Team..