---
schema_version: "1"
id: 5c50670db06a7dda0bb5dc851437227ca49db7a593f4719acbb7f48edd8190a6
title: ContentDownloadHandler Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_Sfc_ContentDownloadHandler.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Sfc_ContentDownloadHandler.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 19c7058db5c57d6ec7fc4c84f349fb392196b2f196c4842e464e7e83cb035b95
description: Use ContentDownloadHandler to define a custom download handler that controls how content is downloaded.A customized error message explaining why the download isn’t allowed.Indicates whether or not download is allowed.The URL the user is redirected to when the download action isn't available, for applying Information Rights Management (IRM) control, virus scanning, or other behavior.
---
# ContentDownloadHandler Class

Use ContentDownloadHandler to define a custom download handler that controls how content is downloaded.

## Namespace

[Sfc](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Sfc.htm#apex_namespace_Sfc "The Sfc namespace contains classes used in Salesforce Files.")

- **[ContentDownloadHandler Properties](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Sfc_ContentDownloadHandler.htm#apex_Sfc_ContentDownloadHandler_properties)**

## ContentDownloadHandler Properties

The following are properties for ContentDownloadHandler.

- **[downloadErrorMessage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Sfc_ContentDownloadHandler.htm#apex_Sfc_ContentDownloadHandler_downloadErrorMessage)**  
    A customized error message explaining why the download isn’t allowed.
- **[isDownloadAllowed](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Sfc_ContentDownloadHandler.htm#apex_Sfc_ContentDownloadHandler_isDownloadAllowed)**  
    Indicates whether or not download is allowed.
- **[redirectUrl](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Sfc_ContentDownloadHandler.htm#apex_Sfc_ContentDownloadHandler_redirectUrl)**  
    The URL the user is redirected to when the download action isn't available, for applying Information Rights Management (IRM) control, virus scanning, or other behavior.

### downloadErrorMessage

A customized error message explaining why the download isn’t allowed.

#### Signature

public String downloadErrorMessage {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

This message is used if a redirectUrl is not provided. If the download is not allowed, Salesforce will throw a ContentCustomizedDownloadException exception that contains the downloadErrorMessage.

### isDownloadAllowed

Indicates whether or not download is allowed.

#### Signature

public Boolean isDownloadAllowed {get; set;}

#### Property Value

Type: [Boolean](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm#apex_methods_system_boolean "Contains methods for the Boolean primitive data type.")

### redirectUrl

The URL the user is redirected to when the download action isn't available, for applying Information Rights Management (IRM) control, virus scanning, or other behavior.

#### Signature

public String redirectUrl {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

The URL must be a valid relative URL. For example, the redirect can be a custom Visualforce page such as “/apex/IRMControl”. URLs with no path, such as “www.domain.com”, results in an InvalidParameterValueException.