# Get Preview URL

Get preview URLs for one or more files from Apex.

> Kind: Apex method · Updated: 2026-07-01

## Signature

```apex
global static List<string> getPreviewUrls(
  List<Resource> resources,
  PreviewParams params,
  String library,
  String runAs
)
```

### Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| resources | List&lt;<a href="#/apex-type-resource">Resource</a>&gt; | required | A list of Resource records to generate preview URLs for. |
| params | <a href="#/apex-type-preview-params">PreviewParams</a> | required | A custom type. PreviewParams has a Boolean allowDownload property. |
| library | String | required | Target storage library. |
| runAs | String | optional | Username to attribute the operation to; defaults to the integration user. |

## Return Type

List<String&gt; — the preview URLs.

## Example

```apex
List<String> previewUrls = new List<String>();
cldfs.PreviewParams PreviewParams = new cldfs.PreviewParams();
PreviewParams.allowDownload = true;

previewUrls = cldfs.Client.getPreviewUrls(
  new List<cldfs.Resource>{
    new cldfs.Resource(
      '001XXXXXXXXXXX',
      'file',
      'image.png',
      'library',
      'driveId'
    )
  },
  PreviewParams,
  'library',
  'integrationUser'
);
```
