Returns a temporary, expiring URL for a single file's Preview.
Only works for a file that already has a generated preview. S-Drive generates previews automatically for supported file types (documents, images, videos) when the Preview and Thumbnail feature is enabled — if a file has no preview, this returns an error.
How to call this method
global static String getPreviewURL(String parentId, String fileObjectId, Long timeValue)
global static String getPreviewURL(String parentId, String fileObjectId, Long timeValue, Map<String,String> requestParameters)
Parameters
|
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
|
|
Yes |
Id of the parent object the file belongs to. Accepts both 15- and 18-character Salesforce Id formats. |
|
|
|
Yes |
Id of the file record to get a preview URL for. To get an older version's preview instead of the current one, pass that version's file record Id here. |
|
|
|
Yes |
How long the URL stays valid, in seconds. |
|
|
|
No |
Extra request parameters for the URL — most notably |
Return value
Returns a String — the URL for the file's preview.
Example
String previewURL = cg.SDriveTools.getPreviewURL(acct.Id, fileId, 1 * 60); // expires in one minute