File

Download link

Binary files can be downloaded through the content/download view. This view accepts 2 ordered URL parameters:

  • the content object id (mandatory)
  • the id of the file attribute inside the content object (mandatory)

In addition to these ordered parameters, an unordered parameter version can be used to set the version of the file you want to download.

The content/read policy as used for download access control. If you use the version unordered parameter to download another version than the current one, then the content/versionread policy will be used instead.

In the standard eZ publish templates an additional part is appended to the download link: /file/ + the URL encoded form of the original file name. This is not necessary for the download to be processed correctly.

Binary file handlers

By using another binary file handler, you can change the way eZ publish handles downloading a file. There are two binary file handlers included with eZ publish by default:

  • passtrough, kernel/classes/binaryhandlers/ezfilepasstrough/ezfilepasstroughhandler.php (default)
  • direct, kernel/classes/binaryhandlers/ezfiledirect/ezfiledirecthandler.php

Passtrough handler

The passthrough handler will present the file through PHP code to the client.

Direct handler

The direct handler will only change the binary file view template used by {attribute_view_gui}. The template used, ezbinaryfile_direct.tpl, uses the real path to the file stored on the web server, so the content/download module is not used and no policies are checked. Make sure you have the right rewrite rule conditions in your Apache configurtion, otherwise the directories where the binary files are stored (var/.../storage/original) are not directly accessible.

Using the direct handler is not recommend, and probably won't work in a clustered setup.

External resources