I need to resolve the real URL for an image (multimedia component) only knowing its tcm-uri and the publication id.
I've tried this way:
var uri = new TcmUri("tcm:13-5093");
var binaryLink = new BinaryLink(13);
var link = binaryLink.GetLink(uri.ToString(), "", "", "", false);
if (link.IsResolved)
var image = link.Url;
but my link variable results always unresolved. I've also tried this way:
BinaryMetaFactory binaryMetaFactory = new BinaryMetaFactory();
BinaryMeta binaryMeta = binaryMetaFactory.GetBinaryMeta("tcm:13-5093");
if(binaryMeta!=null) {
Response.Write("Path of the binary: " + binaryMeta.UrlPath);
}
But even this was not a good solution. My multimedia components are all correctly published so I don't have any idea. Can anyone help me?