Newer Version Available

This content describes an older version of this product. View Latest

Get a File Preview

This example calls 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}