S-Drive 3.6 Documentation

getPreviewURL

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

parentId

String

Yes

Id of the parent object the file belongs to. Accepts both 15- and 18-character Salesforce Id formats.

fileObjectId

String

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.

timeValue

Long

Yes

How long the URL stays valid, in seconds.

requestParameters

Map<String,String>

No

Extra request parameters for the URL — most notably response-content-disposition, which controls whether the URL opens the preview inline or downloads it. See getPreviewURLs for the full explanation.

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