2

Recommend please some way, how to implement preventing downloading files from Partner Portal for particular users?

For these users, files must be VIEW ONLY without any ability to download them

1 Answer 1

5

You can take a look at ContentDownloadHandlerFactory and ContentDownloadHandler to implement your own custom solution.

When a download is triggered either from the UI, Connect API, or an sObject call retrieving ContentVersion.VersionData, implementations of the Sfc.ContentDownloadHandlerFactory are looked up. If no implementation is found, download proceeds. Otherwise, the user is redirected to what has been defined in the ContentDownloadHandler#redirectUrl property. If several implementations are found, they are cascade handled (ordered by name) and the first one for which the download isn’t allowed is considered.

For instance:

public class ContentDownloadHandlerFactoryImpl implements Sfc.ContentDownloadHandlerFactory {
    public Sfc.ContentDownloadHandler getContentDownloadHandler(
        List<Id> ids, Sfc.ContentDownloadContext context
    ) {
        Sfc.ContentDownloadHandler contentDownloadHandler = new Sfc.ContentDownloadHandler();
        if(UserInfo.getProfileId() == '005xx000001SvogAAC') {
            contentDownloadHandler.isDownloadAllowed = true;
            return contentDownloadHandler;
        }
        if(context == Sfc.ContentDownloadContext.MOBILE) {
            contentDownloadHandler.isDownloadAllowed = false;
            contentDownloadHandler.downloadErrorMessage = 
            'Downloading a file from a mobile device isnt allowed.';
            return contentDownloadHandler;
        }
        contentDownloadHandler.isDownloadAllowed = false;
        contentDownloadHandler.downloadErrorMessage = 
        'This file needs to be IRM controlled. Youre not allowed to download it';
        contentDownloadHandler.redirectUrl ='/apex/IRMControl?Id='+ids.get(0);
        return contentDownloadHandler;
    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .