3

We're currently storing PDF files as binaries in Tridion (SDL Tridion 2013 SP1) and using DD4T, we can retrieve these files and display them as a list of links.

What I want to know is if it's possible to get the binary content of these files in the solution (instead of their URL, title, etc.) so that I can process it (calculate the file size and get the file extension).

When accessing the component presentation as shown by a code sample below, I'm only able to retrieve component, component template, page, order on page, etc.

public ActionResult RandomLinks(IComponentPresentation componentPresentation)
{
    if (componentPresentation == null) throw new ArgumentNullException("componentPresentation");
    var model = ComponentViewModelBuilder.Build<RandomLinksViewModel>(componentPresentation.Component);

    return View(model);
}

Is there a way to retrieve the content similar to the Tridion.Extensions.Mediators.Razor.Models:

var binaryContent = component.TridionObject.BinaryContent;

Any help would really be appreciated.

5

DD4T comes with an HTTPModule to stream binary content out of your MVC application.
It does not otherwise expose APIs to access binary content stored in Tridion. You could of course just use the Tridion API directly (not the one you mention; that's a CM API; use the .Net CD API):

(new BinaryFactory()).GetBinary(tcmUri).InputStream

or

(new BinaryFactory()).GetBinary(tcmUri).Bytes

Note that most meta information about your binary is stored in a BinaryMeta object you need to get from the BinaryMetaFactory; only the size of the binary is included in BinaryData as the DataSize property.

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.