Adding raw binaries to a Web page

Use the BinaryFactory class in Java or .NET to specify a Publication ID and binary ID to get the raw contents of a binary file stored in the Content Data Store.

The Content Delivery APIs contain a class called BinaryFactory that lets you retrieve the raw contents of a binary file.

Java/JSP

In Java, the fully qualified class name is com.tridion.content.BinaryFactory. You retrieve the binary by making a call to the getBinary method, which has a number of different signatures. If the item has no variants, use this signature:

public BinaryData getBinary(final int publicationId, final int binaryId)

If it does have variants, use this one:

public BinaryData getBinary(final int publicationId, 
  final int binaryId, final String variantId)

Instead of a Publication ID and binary ID, you can also specify the Content Manager URI of the binary, resulting in the following signatures:

public BinaryData getBinary(final String binaryTCMURI)

and

public BinaryData getBinary(final String binaryTCMURI, final String variantId)

The binary is returned in an object of class com.tridion.data.BinaryData

.NET

In .NET, the fully qualified class name is Tridion.ContentDelivery.DynamicContent.BinaryFactory. You retrieve the binary by making a call to the GetBinary method, which has a number of signatures. If the item has no variants, use this signature:

public BinaryData GetBinary(int publicationId, int binaryId)

If it does have variants, use this one:

public BinaryData GetBinary(int publicationId, int binaryId, string variantId)

Instead of a Publication ID and binary ID, you can also specify the Content Manager URI of the binary, resulting in the following signatures:

public BinaryData GetBinary(string binaryTCMURI)

and

public BinaryData GetBinary(string binaryTCMURI, string variantId)

The binary is returned in an object of class Tridion.ContentDelivery.DynamicContent.BinaryData

The returned BinaryData object contains:

  • a unique ID for this binary
  • the ID of its Publication
  • the ID of this specific variant
  • a byte array containing the raw binary data
  • a stream that represents the binary data