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 Repository Folder Items
Call a method to get a collection of repository folder items.
Call getRepositoryFolderItems(repositoryId, repositoryFolderId) to get the
collection of items in a repository folder. For files, we show the file’s name, size, external
URL, and download URL. For folders, we show the folder’s name, description, and external
URL.
1final String gDriveRepositoryId = '0XCxx00000000ODGAY', gDriveFolderId = 'folder:0B0lTys1KmM3sSVJ2bjIzTGFqSWs';
2final ConnectApi.RepositoryFolderItemsCollection folderItemsColl = ConnectApi.ContentHub.getRepositoryFolderItems(gDriveRepositoryId,gDriveFolderId);
3final List<ConnectApi.RepositoryFolderItem> folderItems = folderItemsColl.items;
4System.debug('Number of items in repository folder: ' + folderItems.size());
5for(ConnectApi.RepositoryFolderItem item : folderItems){
6 ConnectApi.RepositoryFileSummary fileSummary = item.file;
7 if(fileSummary != null){
8 System.debug(String.format('File item - name: \'\'{0}\'\', size: {1}, external URL: \'\'{2}\'\', download URL: \'\'{3}\'\'', new String[]{ fileSummary.name, String.valueOf(fileSummary.contentSize), fileSummary.externalDocumentUrl, fileSummary.downloadUrl}));
9 }else{
10 ConnectApi.RepositoryFolderSummary folderSummary = item.folder;
11 System.debug(String.format('Folder item - name: \'\'{0}\'\', description: \'\'{1}\'\'', new String[]{ folderSummary.name, folderSummary.description}));
12 }
13}