Working with Zend Download Server

bulb.gifThis component is not relevant for Windows and IBM i Servers.

 

The Zend Download Server (ZDS) can be used to increase your Apache Web server's capacity by automatically taking over static downloads. This releases Apache processes to handle more dynamic requests.

 

Files can be sent through the ZDS in two ways:

  1. Automatically - By configuring Apache to pass specific file types to PHP: For example, images, PDF files or any other relatively large static files. When the ZDS is loaded and configured, PHP passes the request to the ZDS, which takes over sending the file to the user.

  2. Manually - By calling the Zend Download Server API functions from within your PHP script. This is useful for situations where you require some code or logic to run before allowing a download, such as authenticating users before permitting them to download.

Configuring Zend Download Server to Automatically Handle Files

This procedure describes how to configure your environment to handle certain file types with the ZDS.

Although transparent to end users, this action is expected to increase server capacity.

 

 

Instructions on how to complete a procedure

To set up ZDS to automatically handle specific file types:

  1. Locate the Apache configuration file that contains the PHP handler configuration by searching for the line starting with "AddHandler php5-script" (you can do this using grep or similar tools). This line defines the file extensions that are passed to PHP.

  2. Add the extensions of the file types you want ZDS to handle at the end of this line.

  3. Make sure that the same file extension is listed in the ZDS MIME type configuration file located in <install_path>/etc/zend_mime_types.ini. If not, add it and make sure to define the correct MIME type for it. The configured MIME type is sent as the value of the "Content-type" HTTP response header, which (according to the browser's individual settings) determines the browser's behavior when it receives the file.

  4. Save your files and restart the Apache server.

All the defined files types are now handled by the ZDS (as long as this component is set to 'On' in the Administration Interface).

Sending Files Using the Zend Download Server API

This procedure describes how to call the ZDS API functions from within your code, to handle specific types of file downloads.

Although transparent to end-users, this action is expected to increase server capacity.

 

The following example demonstrates the logical flow of sending a file using ZDS. In this example, the download only proceed if the user is authenticated.

Usage Example

Example:

if ($user->isAuthenticated()) {

    zend_send_file($filename, $mime_types, $headers);    

    // -- execution stops here --

} else {

    echo "Sorry, you are not authorized to download this file.";   

}

If the user is not authenticated, the download does not begin and the following message is displayed:  "Sorry, you are not authorized to download this file."

 

 

Related Links

Related Links:

Components

ZDS (Zend Download Server)

Zend Download Server - Configuration Directives

Zend Download Server - PHP API