Newer Version Available
Get Previews
This example calls getPreviews(repositoryId, repositoryFileId) 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.
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}