I have publicly accessible files in Salesforce (accessible by anyone, even without a Salesforce license), which can be accessed via URLs such as this:
https://XXXXXXXX.my.salesforce.com/sfc/p/#58000000Og0w/a/4H000001BDWe/FG3cuoiwxYaI_SGe9ZYC9swLPnX.88vSoqwtw9EgRH8
However, this is a page that displays the file with a download link. I would like to have a link to the file itself, without any HTML wrapping it. With googling I found that there are links like
https://<YOUR_SFDC_BASE_URL>/sfc/servlet.shepherd/version/download/068XXXXXXXXXXXX
that should do that, but they require a Content Version record Id, which always starts with 068. As you can see, the original URL does not contain something like that. Is there a way to programmatically derive the second URL from the first URL?
UPDATE: Yrc Shk suggests to use the DistributionPublicUrl object. Creating such an object from a ContentVersion gives you several URLs:
- ContentDownloadUrl
- DistributionPublicUrl
- PdfDownloadUrl
Where DistributionPublicUrl is the URL that I started with, the page that allows you to download a file. The other two URLs appear to be the ones linked to the two Download buttons on that page.
But what I am really looking for, I'll say it more carefully now, is a URL to a page that displays just the file, without an HTML wrapper, without automatic downloading (a user might choose to download using the browser).