---
schema_version: "1"
id: 78018c265fa9c719033c8047e027b348810c52e268a087062c74c51207687c85
title: ContentDownloadHandlerFactory Interface
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_interface_Sfc_ContentDownloadHandlerFactory.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_Sfc_ContentDownloadHandlerFactory.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 57b4b6ae461bf674a9a7f89d3877ec84e4e8caebac62c10bdc194178a5378b91
description: Use this interface to provide a class factory that Salesforce can call to create instances of your custom ContentDownloadHandler. Returns a ContentDownloadHandler for a given list of content IDs and a download context.
---
# ContentDownloadHandlerFactory Interface

Use this interface to provide a class factory that Salesforce can call to create instances of your custom ContentDownloadHandler.

## 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.")

## Usage

ContentDownloadHandler getContentDownloadHandler(List<ID> ids, ContentDownloadContext context);

- **[ContentDownloadHandlerFactory Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_Sfc_ContentDownloadHandlerFactory.htm#apex_Sfc_ContentDownloadHandlerFactory_methods)**
- **[ContentDownloadHandlerFactory Example Implementation](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_Sfc_ContentDownloadHandlerFactory.htm#apex_interface_Sfc_ContentDownloadHandlerFactory_Example)**

## ContentDownloadHandlerFactory Methods

The following are methods for ContentDownloadHandlerFactory.

- **[getContentDownloadHandler(var1, var2)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_Sfc_ContentDownloadHandlerFactory.htm#apex_Sfc_ContentDownloadHandlerFactory_getContentDownloadHandler)**  
    Returns a ContentDownloadHandler for a given list of content IDs and a download context.

### getContentDownloadHandler(var1, var2)

Returns a ContentDownloadHandler for a given list of content IDs and a download context.

#### Signature

public Sfc.ContentDownloadHandler getContentDownloadHandler(List<Id> var1, Sfc.ContentDownloadContext var2)

#### Parameters

- **var1**:
    
    Type: List<Id>
- **var2**:
    
    Type: [Sfc.ContentDownloadContext](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_Sfc_ContentDownloadContext.htm#apex_enum_Sfc_ContentDownloadContext "This enum specifies the download context.")

#### Return Value

Type: [Sfc.ContentDownloadHandler](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Sfc_ContentDownloadHandler.htm#apex_class_Sfc_ContentDownloadHandler "Use ContentDownloadHandler to define a custom download handler that controls how content is downloaded.")

## ContentDownloadHandlerFactory Example Implementation

This example creates a class that implements the Sfc.ContentDownloadHandlerFactory interface and returns a download handler that blocks downloading content to mobile devices.

// Allow customization of the content Download experience
public with sharing class ContentDownloadHandlerFactoryImpl implements Sfc.ContentDownloadHandlerFactory {

  public Sfc.ContentDownloadHandler getContentDownloadHandler(List<ID\> ids, Sfc.ContentDownloadContext context) {
    Sfc.ContentDownloadHandler contentDownloadHandler = new Sfc.ContentDownloadHandler();

    if(context == Sfc.ContentDownloadContext.MOBILE) {
      contentDownloadHandler.isDownloadAllowed = false;
      contentDownloadHandler.downloadErrorMessage = 'Downloading a file from a mobile device is not allowed.';
      return contentDownloadHandler;
    }
    contentDownloadHandler.isDownloadAllowed = true;
    return contentDownloadHandler;
  }
}