---
schema_version: "1"
id: 669b7430c699fe58b34679b21789e984987dc12f8c8f60bf418fccab368b23fe
title: Get Previews
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/connectapi_examples_get_previews.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/connectapi_examples_get_previews.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 8e884d08e9156922e4d4fbb0c4b4d3ab1cb7fd7dca7c5cba114f7a7303338551
description: Call a method to get all supported preview formats and their respective URLs.
---
# Get Previews

Call a method to get all supported preview formats and their respective URLs.

Call [getPreviews(repositoryId, repositoryFileId)](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexref.meta/apexref/apex_ConnectAPI_ContentHub_static_methods.htm#apex_ConnectAPI_ContentHub_getPreviews_1) to get all supported preview formats and their respective URLs and number of renditions. For each supported preview format, we show every rendition URL available.

final String gDriveRepositoryId = '0XCxx00000000ODGAY', gDriveFileId = 'document:1-zcA1BaeoQbo2\_yNFiHCcK6QJTPmOke-kHFC4TYg3rk';
final ConnectApi.FilePreviewCollection previewsCollection = ConnectApi.ContentHub.getPreviews(gDriveRepositoryId, gDriveFileId);
for(ConnectApi.FilePreview filePreview : previewsCollection.previews){
   System.debug(String.format('Preview - URL: \\'\\'{0}\\'\\', format: \\'\\'{1}\\'\\', nbr of renditions for this format: {2}', new String\[\]{ filePreview.url, filePreview.format.name(),String.valueOf(filePreview.previewUrls.size())}));
   for(ConnectApi.FilePreviewUrl filePreviewUrl : filePreview.previewUrls){
      System.debug('-----> Rendition URL: ' + filePreviewUrl.previewUrl);
      }
}