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 |
|---|---|---|---|
|
|
|
Yes |
Salesforce Ids of the parent objects, one per file, in the same order as |
|
|
|
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. |
|
|
|
Yes |
How long the URLs stay valid, in seconds. |
|
|
|
No |
Extra request parameters applied to every URL — most notably |
|
|
|
No |
Same idea, but one map per entry in |
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);