You are not providing enough information in your question. And from the information you do provide, I think you are on the wrong path.
If you are on the server and want to retrieve Binary
content, then you need to call the DD4T BinaryFactory
and pass in the URL or TCMURI of the binary.
This is usually done in the BinaryController
where you have the Binary URL. Sample code below:
@RequestMapping(method = {RequestMethod.GET, RequestMethod.HEAD})
public void getBinary(final HttpServletRequest request, final HttpServletResponse response) {
String binaryPath = getBinaryPath(request);
int publicationId = publicationResolver.getPublicationId();
Binary binary = binaryFactory.getBinaryByURL(binaryPath, publicationId);
...
}
Then comes the delivery part, where you need to fill the Response object with the binary content and let it go back to the browser.
Naturally you would need caching to be done here, as you don't want to hit your BinaryProvider
for each request. Some of the caching is done in the BinaryFactory
, but you might want to implement some additional yourself.
Next, you will need to handle cache headers in request/response (if-modified-since, last-modified).
Finally, you will need error handling for corner cases (DB down, binary not published, exceptions from provider tier, etc).