Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

ContentDownloadHandlerFactory Interface

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

Namespace

Sfc

Usage

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

ContentDownloadHandlerFactory Methods

The following are methods for ContentDownloadHandlerFactory.

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

Return Value

Type: Sfc.ContentDownloadHandler

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.

1// Allow customization of the content Download experience
2public class ContentDownloadHandlerFactoryImpl implements Sfc.ContentDownloadHandlerFactory {
3
4  public Sfc.ContentDownloadHandler getContentDownloadHandler(List<ID> ids, Sfc.ContentDownloadContext context) {
5    Sfc.ContentDownloadHandler contentDownloadHandler = new Sfc.ContentDownloadHandler();
6
7    if(context == Sfc.ContentDownloadContext.MOBILE) {
8      contentDownloadHandler.isDownloadAllowed = false;
9      contentDownloadHandler.downloadErrorMessage = 'Downloading a file from a mobile device is not allowed.';
10      return contentDownloadHandler;
11    }
12    contentDownloadHandler.isDownloadAllowed = true;
13    return contentDownloadHandler;
14  }
15}