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.

// 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;
  }
}