Creating File Links
S-Drive gives you two different kinds of link, used for two different audiences.
getAttachmentURL and getAttachmentURLs generate a signed, expiring URL for your own Salesforce-side code to use — rendering an image inline on a Visualforce page, linking to a file from a custom component, etc. The person hitting the link is assumed to already have whatever Salesforce access got them to the page or component in the first place; these methods just bridge from Salesforce to the file sitting in storage.
createPublicLink and createPublicDownloadLink are for the opposite case: sharing with the public, no Salesforce login involved at all. Since there's no login, they have their own access controls instead — separate read/update/delete/create flags, an optional password, an optional IP range, and an expiration date.
Note that createPublicDownloadLink is the same functionality as calling createPublicLink and specifying that the link be for downloads. createPublicDownloadLink doesn’t require passing the parent id or relationship name, making it a little simpler.
|
Method |
Audience |
Files at once |
Access control |
Expires |
|---|---|---|---|---|
|
|
Your own Apex/Visualforce/LWC code |
One |
Whatever the calling code's own access already governs |
Yes — you specify seconds |
|
|
Your own Apex/Visualforce/LWC code |
Many (batch) |
Same as above |
Yes — you specify seconds |
|
|
The public — no Salesforce login required |
Many (files and/or folders together) |
Configurable per link: read / update / delete / create, optional password, optional IP range |
Yes — you specify a date |
|
|
The public — no Salesforce login required |
Many (files and/or folders together) |
Download only |
Yes — you specify a date |