Files attached to Accounts in Salesforce are not publicly addressable. This gist explains how to use them in another context, so that they can be accessed by non-authenticated users. It assumes you are able to query Salesforce with the REST API connected via OAuth 2.0.
- Get an account record identified by
{id}
and return any attached files:
SELECT Id, Name, (ContentDocumentid FROM AttachedContentDocuments) FROM Account WHERE Id = {id}
- Use (one of) the returned
ContentDocumentid
s to retrieve the a link to latest version of the file you're interested in. This will return an API URL that can be used to retrieve the file contents:
SELECT VersionData FROM ContentVersion WHERE ContentDocumentId = 'XXXXXXXXX' AND IsLatest = true
- Request the API URL, e.g.
/services/data/v46.0/sobjects/ContentVersion/YYYYYYYYY/VersionData
to return the binary data of the file. You can either stream directly to the browser with appropriate headers, or (much better) save as a file and serve that to your non-authenticated users.