Loading

Troubleshooting File Download Issues with ContentDownloadHandlerFactory and Public Links

Veröffentlichungsdatum: Oct 6, 2025
Beschreibung

If you are experiencing issues with file downloads via Content Delivery links (Public Links) after implementing the ContentDownloadHandlerFactory Apex interface, this article provides common causes and solutions. 

Symptoms

  • Users are unable to download files via Content Delivery/Public links on your Salesforce org or Experience Cloud site.

  • File downloads stop working after making changes to your Apex class implementing the ContentDownloadHandlerFactory interface.

  • No error message is displayed to the end-user during the failed download attempt.

Lösung

This behavior is not a bug or a platform malfunction but rather a consequence of how ContentDownloadHandlerFactory interacts with the highly secure and restricted "External Who" user context. Here are two recommended approaches to address this:

  1. Modify Your ContentDownloadHandlerFactory implementation to bypass specific checks for the "External Who" User:

    • Adjust your Apex code within the ContentDownloadHandlerFactory implementation to identify and bypass specific logic (e.g., SOQL queries for user details) when the code is executed in the context of the "External Who" user.

    • You can identify this context by checking for unique, constant properties of the "External Who" user, such as its name or ID, and then conditionally skipping any problematic queries or logic that rely on standard user access.

  2. Implement Robust Exception Handling:

    • Wrap any Apex code in your ContentDownloadHandlerFactory implementation that queries user details or might otherwise fail in a restricted context with try-catch blocks.

    • This allows your code to gracefully handle the "List has no rows for assignment to SObject" exception or similar errors without interrupting the Content Delivery process. You can then implement fallback logic or simply allow the process to continue if those specific user details are not critical for file delivery.

By implementing one of these solutions, you can ensure your ContentDownloadHandlerFactory class operates correctly without encountering issues in the restricted "External Who" user context, thereby restoring successful file downloads via Content Delivery links.

Zusätzliche Ressourcen

Understanding the Cause

When files are downloaded via Content Delivery links, Salesforce's Content Platform uses a unique internal user context to serve these links. This "External Who" user is distinct and has very restricted permissions, designed solely for handling Content Delivery. Many standard platform features, including direct access to certain user record details or sharing, do not function in this user's context.

If your ContentDownloadHandlerFactoryimplementation includes Apex code that attempts to query or access details of the currently running user (e.g., performing a SOQL query on the User object for additional information), this query will fail when executed in the "External Who" user's context. Since this internal user is designed with minimal access, it cannot retrieve its own record details as a standard user would. This failure in your Apex code then prevents the file download from completing, even though no error is displayed to the end-user.

The underlying error could sometimes be recorded in Apex logs is "List has no rows for assignment to SObject", indicating that a query for user details returned no results within the restricted context of the "External Who" user.

Nummer des Knowledge-Artikels

004980253

 
Laden
Salesforce Help | Article