tridiontridion-2011tridion-content-delivery

Does the BinaryFactory work for binaries on the file system?


I'm trying to read the binary data of a published binary using the following code:

Tridion.ContentDelivery.DynamicContent.BinaryFactory factory = new BinaryFactory();
BinaryData binaryData = factory.GetBinary(uri.ToString());

This worked fine, until I deployed it in an environment where the binaries are stored on the file system rather than the broker database. Now, the BinaryData is always null, even though I'm sure that the file exists.

Is it mandatory to store your binaries in a database if you want to use the BinaryFactory like this? Or am I missing something?


Solution

  • I just ran some tests on my SDL Tridion 2011 SP1 HR1 environment, and can confirm that BinaryData is populated (i.e. not null and contains values) when my binaries are on the file system. I used your code sample, and just added a valid URI of a binary that is used on a page on my website. I am not sure what is different between our environments, my only thought would be to check that BinaryMeta is deployed to your Broker Database (although if this makes a difference I would think it is a bug).

    The ItemTypes node of my cd_storage.xml node is as follows:

    <ItemTypes defaultStorageId="defaultdb" cached="true">
        <Item typeMapping="Binary" storageId="defaultFile" cached="true"/>
    </ItemTypes>
    

    So everything except the binaries are in the DB.

    I am not sure what version of SDL Tridion you are using (and i have no idea if it would impact this), but I recently heard that storing any metadata on the file system is no longer supported as of 2011 SP1.