1

I am trying to get the binary URL from Broker DB. I tried the below content delivery API. I am getting null value. But binary is published into Broker and it is available when I query the DB. Any thoughts on this?

I tried with fully qualified TCM ID of the binary as well as binary short ID.

 //create a new BinaryMetaFactory instance:
            BinaryMetaFactory binaryMetaFactory12 = new BinaryMetaFactory();
            //find the metadata for the specified binary
            BinaryMeta binaryMeta12 = binaryMetaFactory12.GetMeta("tcm:255-14072");
            //print the path to the output stream:
            if (binaryMeta12 != null)
            {

            }

other way

 Tridion.ContentDelivery.DynamicContent.BinaryFactory factory = new BinaryFactory(); 
            //BinaryData binaryData = factory.GetBinary("14072".ToString());
            BinaryData binaryData = factory.GetBinary(Convert.ToInt32(255), Convert.ToInt32(14072));
2
  • Aren't you specifying the Publication ID and Binary ID parameters in the wrong order to BinaryFactory.GetBinary? You may also have to specify a Variant ID. See, for example: github.com/sdl/dxa-web-application-dotnet/blob/master/… Jan 16 '17 at 20:44
  • Hi Rick: I was checking the "BinaryData" class instead "BinaryMeta" class. However, I am filtering the binary based on publication id and some other criteria. I want to get the URL of the results. So, I am not able to pass the "variant id" for each binary because it might vary binary to binary and I don't get the details. So, is there any way to get binary URL by using publication id and item id or fully qualified binary tcm id?
    – Jey
    Jan 17 '17 at 20:07
2

If your Binaries have a Variant ID, but you don't know this Variant ID when you request the Binary, you can use BinaryMetaFactory.GetAllVariantMeta. It has the following signature:

BinaryMeta[] GetAllVariantMeta(string binaryUri)

Note that it may return multiple BinaryMeta objects, because you may have multiple Binaries with the same ID but with different Variant IDs (that is the whole purpose of Variant ID).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.