Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Get a File Preview
Call a method to get a file preview.
Call getFilePreview(repositoryId,
repositoryFileId, formatType) with a formatType of Thumbnail to get the
thumbnail format preview along with its respective URL and number of thumbnail renditions. For
each thumbnail format, we show every rendition URL
available.
1final String gDriveRepositoryId = '0XCxx00000000ODGAY', gDriveFileId = 'document:1-zcA1BaeoQbo2_yNFiHCcK6QJTPmOke-kHFC4TYg3rk';
2final ConnectApi.FilePreviewCollection previewsCollection = ConnectApi.ContentHub.getPreviews(gDriveRepositoryId, gDriveFileId);
3for(ConnectApi.FilePreview filePreview : previewsCollection.previews){
4 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())}));
5 for(ConnectApi.FilePreviewUrl filePreviewUrl : filePreview.previewUrls){
6 System.debug('-----> Rendition URL: ' + filePreviewUrl.previewUrl);
7 }
8}