I have a Site, where external, unauthenticated users can access some of the files we store in Salesforce. To achieve this, I use Content Distribution records, to obtain the public URLs for these files. The Visualforce page displayed in the Site has a controller, which queries related ContentDistribution records and displays the links. This was working fine up until a few days ago (possibly up until the Winter'19 release).

Currently when external users try to access the files, the controller throws an error: sObject type 'ContentDistribution' is not supported

As a workaround I moved querying ContentDistribution to a without sharing class and use a Custom wrapper class to hold the name and URL of the file, but this doesn't seem like a good solution in the long term.

Is there any new feature or critical update, that I missed, that takes away access to ContentDistribution from public Site users? And if so, is there any better way to allow unauthenticated users see/download files from a Salesforce org?

I know about the "share via link" option on files - but I haven't found any resources on how to use it programmatically (both to create the public link and to query it).

  • if you can log a case with support you might be able to get some traction, just make sure to call it out as a "Regression" and be very clear the same code worked prior to Winter '19. With a bit of luck you might get through to someone knowledgeable who can steer you around whatever issue has come up, and or tell you they intentionally broke your stuff and it's never coming back (hopefully not) Commented Nov 7, 2018 at 6:24
  • ps there was also a recent critical update which recent some permission for guest user profiles, you might double check the profile settings still grant access to that document Commented Nov 7, 2018 at 6:25
  • Thanks. I have logged a case as well. Will update here if I find out anything. Commented Nov 7, 2018 at 10:41
  • Unfortunately, Support's answer is that Content Delivery records were never meant to be accessed by Guest users (so I guess in the past this was working unintentionally). They have pointed me to the critical update you mentioned: releasenotes.docs.salesforce.com/en-us/winter19/release-notes/… and also this Idea: success.salesforce.com/ideaView?id=08730000000cH2vAAE. "Sigh!" :( I'll leave the question open in case someone will have a good idea on how to deal with this in the post-Winter'19 world Commented Nov 12, 2018 at 8:45

2 Answers 2


The answer is to use a without sharing class that does access control and only delivers the data the current guest user is allowed to access. You should not be granting declarative access to objects to guest users as there is no way to distinguish them. In your controller, you can distinguish them.

In general when you have guest users your controllers will need to be without sharing. Of course this requires you to be very careful in implementing your own procedural access control logic, but that's better than granting blanket access to anonymous internet users to read your organization's data. For example if you have a without sharing controller you can do things like use secure tokens in cookies, rely on a third party service to identify the user, and require captchas. A combination of these techniques can allow you to add your own access control logic when dealing with guest users and only serve data to them which they are allowed to see. But if you mark an object as accessible to the guest user, then they can use standard controllers to access that object at any time, and your code will not be able to deny them access.

For additional examples of using the above patterns in without sharing controllers to give controlled access to guest users, look at this blog post: https://www.learnexperiencecloud.com/s/article/Guest-User-Record-Access-Development-Best-Practices


This helped me. https://forcepanda.wordpress.com/2021/05/04/generating-public-url-for-salesforce-files

Basically you need to generate Public Links using ContentDistribution as mentioned in the above article. Then use an Apex class with 'without sharing' and query this object (Guest users don't have access to this object hence without sharing) to get the ContentDownloadUrl. Use that to render the image files in your component.

  • While this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – identigral
    Commented Feb 24, 2022 at 8:35

You must log in to answer this question.

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