S-Drive 3.6 Documentation

getPreviewURLs

Returns temporary, expiring URLs for multiple file previews at once — the batch version of getPreviewURL.

Only works for files that already have generated preview. S-Drive generates previews automatically for supported file types (documents, images, videos) when the Preview and Thumbnail feature is enabled . If some files in the list do not have previews, the returned value for those will be “N/A”. If none have previews, it will return an error.

How to call this method

global static List<String> getPreviewURLs(List<ID> parentIds, List<ID> fileObjectIds, Long timeValue)

global static List<String> getPreviewURLs(List<ID> parentIds, List<ID> fileObjectIds, Long timeValue, Map<String,String> requestParameters)

global static List<String> getPreviewURLs(List<ID> parentIds, List<ID> fileObjectIds, Long timeValue, List<Map<String,String>> requestParametersList)

Three overloads: a plain batch, one that applies the same extra request parameters to every file, and one that lets you specify different request parameters per file.

Parameters

Parameter

Type

Required

Description

parentIds

List<ID>

Yes

Salesforce Ids of the parent objects, one per file, in the same order as fileObjectIds.

fileObjectIds

List<ID>

Yes

Ids of the file records to get preview URLs for. To get an older version's preview, use that version's file record Id.

timeValue

Long

Yes

How long the URLs stay valid, in seconds.

requestParameters

Map<String,String>

No

Extra request parameters applied to every URL — most notably response-content-disposition: include "inline" for a URL that displays the preview in the browser, or "attachment" for one that downloads it.

requestParametersList

List<Map<String,String>>

No

Same idea, but one map per entry in fileObjectIds, same order, for setting different parameters per file.

Return value

Returns List<String> — one preview URL per entry in fileObjectIds, in the same order. For files that don’t have previews, “N/A” will be returned for the file’s URL.

Example

Map<String,String> reqParam = new Map<String,String>{
    'response-content-disposition' => 'inline; filename=preview.png' // 'attachment; ...' would force a download instead
};

List<String> previewURLs = cg.SDriveTools.getPreviewURLs(parentIds, fileIds, 300, reqParam);