public byte[] GetBinaryByUrl(string url) { string encodedUrl = HttpUtility.UrlPathEncode(url); // ?? why here? why now? byte[] retVal = null; //TODO: Add usings instead of fully classified names using (Com.Tridion.Broker.Binaries.Meta.SQLBinaryMetaHome bmHome = new Com.Tridion.Broker.Binaries.Meta.SQLBinaryMetaHome()) { Com.Tridion.Meta.BinaryMeta bm = bmHome.FindByURL(PublicationId, encodedUrl); if (bm == null) { return(retVal); } using (Com.Tridion.Broker.Binaries.SQLBinaryHome binaryHome = new Com.Tridion.Broker.Binaries.SQLBinaryHome()) { Com.Tridion.Data.BinaryData data = binaryHome.FindByPrimaryKey(PublicationId, Convert.ToInt32(bm.GetId()), bm.GetVariantId()); retVal = data.GetBytes(); } } return(retVal); }
public byte[] GetBinaryByUri(string uri) { byte[] retVal = null; using (Com.Tridion.Broker.Binaries.Meta.SQLBinaryMetaHome bmHome = new Com.Tridion.Broker.Binaries.Meta.SQLBinaryMetaHome()) { TCDURI tcdUri = new TCDURI(uri); Com.Tridion.Meta.BinaryMeta bm = bmHome.FindByPrimaryKey(tcdUri); if (bm == null) { return(retVal); } using (Com.Tridion.Broker.Binaries.SQLBinaryHome binaryHome = new Com.Tridion.Broker.Binaries.SQLBinaryHome()) { Com.Tridion.Data.BinaryData data = binaryHome.FindByPrimaryKey(PublicationId, Convert.ToInt32(bm.GetId()), bm.GetVariantId()); retVal = data.GetBytes(); } } return(retVal); }