Newer Version Available

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

ContentHub Class

Access repositories and their files and folders.

Namespace

ConnectApi

ContentHub Methods

The following are methods for ContentHub. All methods are static.

addRepositoryItem(repositoryId, repositoryFolderId, file)

Add a repository item.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFolderItem addRepositoryItem(String repositoryId, String repositoryFolderId, ConnectApi.ContentHubItemInput file)

Parameters

repositoryId
Type: String
The ID of the repository.
repositoryFolderId
Type: String
The ID of the repository folder.
file
Type: ConnectApi.ContentHubItemInput
The item type ID and fields of the item type.

Return Value

Type: ConnectApi.RepositoryFolderItem

Example

This example creates a file without binary content (metadata only) in a repository folder. After the file is created, we show the file’s ID, name, description, external URL, and download URL.

1final String gDriveRepositoryId = '0XCxx00000000ODGAY', gDriveFolderId = 'folder:0B0lTys1KmM3sSVJ2bjIzTGFqSWs';
2
3final ConnectApi.ContentHubItemInput newItem = new ConnectApi.ContentHubItemInput();
4newItem.itemTypeId = 'document'; //see getAllowedTypes for any file item types available for creation/update
5newItem.fields = new List<ConnectApi.ContentHubFieldValueInput>();
6
7//Metadata: name field
8final ConnectApi.ContentHubFieldValueInput fieldValueInput = new ConnectApi.ContentHubFieldValueInput();
9fieldValueInput.name = 'name';
10fieldValueInput.value = 'new folder item name.txt';
11newItem.fields.add(fieldValueInput);
12
13//Metadata: description field
14final ConnectApi.ContentHubFieldValueInput fieldValueInputDesc = new ConnectApi.ContentHubFieldValueInput();
15fieldValueInputDesc.name = 'description';
16fieldValueInputDesc.value = 'It does describe it';
17newItem.fields.add(fieldValueInputDesc);
18
19final ConnectApi.RepositoryFolderItem newFolderItem = ConnectApi.ContentHub.addRepositoryItem(gDriveRepositoryId, gDriveFolderId, newItem);
20final ConnectApi.RepositoryFileSummary newFile = newFolderItem.file;
21System.debug(String.format('New file - id: \'\'{0}\'\', name: \'\'{1}\'\', description: \'\'{2}\'\' \n external URL: \'\'{3}\'\', download URL: \'\'{4}\'\'', new String[]{ newFile.id, newFile.name, newFile.description, newFile.externalDocumentUrl, newFile.downloadUrl}));

addRepositoryItem(communityId, repositoryId, repositoryFolderId, file)

Add a repository item in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFolderItem addRepositoryItem(String communityId, String repositoryId, String repositoryFolderId, ConnectApi.ContentHubItemInput file)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
repositoryId
Type: String
The ID of the repository.
repositoryFolderId
Type: String
The ID of the repository folder.
file
Type: ConnectApi.ContentHubItemInput
The item type ID and fields of the item type.

Return Value

Type: ConnectApi.RepositoryFolderItem

addRepositoryItem(repositoryId, repositoryFolderId, file, fileData)

Add a repository item, including the binary file.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFolderItem addRepositoryItem(String repositoryId, String repositoryFolderId, ConnectApi.ContentHubItemInput file, ConnectApi.BinaryInput fileData)

Parameters

repositoryId
Type: String
The ID of the repository.
repositoryFolderId
Type: String
The ID of the repository folder.
file
Type: ConnectApi.ContentHubItemInput
The item type ID and fields of the item type.
fileData
Type: ConnectApi.BinaryInput
The binary file.

Return Value

Type: ConnectApi.RepositoryFolderItem

Example

This example creates a file with binary content and metadata in a repository folder. After the file is created, we show the file’s ID, name, description, external URL, and download URL.
1final String gDriveRepositoryId = '0XCxx00000000ODGAY', gDriveFolderId = 'folder:0B0lTys1KmM3sSVJ2bjIzTGFqSWs';
2
3final ConnectApi.ContentHubItemInput newItem = new ConnectApi.ContentHubItemInput();
4newItem.itemTypeId = 'document'; //see getAllowedTypes for any file item types available for creation/update
5newItem.fields = new List<ConnectApi.ContentHubFieldValueInput>();
6
7//Metadata: name field
8Final String newFileName = 'new folder item name.txt';
9final ConnectApi.ContentHubFieldValueInput fieldValueInput = new ConnectApi.ContentHubFieldValueInput();
10fieldValueInput.name = 'name';
11fieldValueInput.value = newFileName;
12newItem.fields.add(fieldValueInput);
13
14//Metadata: description field
15final ConnectApi.ContentHubFieldValueInput fieldValueInputDesc = new ConnectApi.ContentHubFieldValueInput();
16fieldValueInputDesc.name = 'description';
17fieldValueInputDesc.value = 'It does describe it';
18newItem.fields.add(fieldValueInputDesc);
19
20//Binary content
21final Blob newFileBlob = Blob.valueOf('awesome content for brand new file');
22final String newFileMimeType = 'text/plain';
23final ConnectApi.BinaryInput fileBinaryInput = new ConnectApi.BinaryInput(newFileBlob, newFileMimeType, newFileName);
24
25final ConnectApi.RepositoryFolderItem newFolderItem = ConnectApi.ContentHub.addRepositoryItem(gDriveRepositoryId, gDriveFolderId, newItem, fileBinaryInput);
26final ConnectApi.RepositoryFileSummary newFile = newFolderItem.file;
27System.debug(String.format('New file - id: \'\'{0}\'\', name: \'\'{1}\'\', description: \'\'{2}\'\' \n external URL: \'\'{3}\'\', download URL: \'\'{4}\'\'', new String[]{ newFile.id, newFile.name, newFile.description, newFile.externalDocumentUrl, newFile.downloadUrl}));

addRepositoryItem(communityId, repositoryId, repositoryFolderId, file, fileData)

Add a repository item, including the binary file, in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFolderItem addRepositoryItem(String communityId, String repositoryId, String repositoryFolderId, ConnectApi.ContentHubItemInput file, ConnectApi.BinaryInput fileData)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
repositoryId
Type: String
The ID of the repository.
repositoryFolderId
Type: String
The ID of the repository folder.
file
Type: ConnectApi.ContentHubItemInput
The item type ID and fields of the item type.
fileData
Type: ConnectApi.BinaryInput
The binary file.

Return Value

Type: ConnectApi.RepositoryFolderItem

getAllowedItemTypes(repositoryId, repositoryFolderId)

Get the item types that the context user is allowed to create in the repository folder.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.ContentHubAllowedItemTypeCollection getAllowedItemTypes(String repositoryId, String repositoryFolderId)

Parameters

repositoryId
Type: String
The ID of the repository.
repositoryFolderId
Type: String
The ID of the repository folder.

getAllowedItemTypes(repositoryId, repositoryFolderId, filter)

Get the item types, filtered by type, that the context user is allowed to create in the repository folder.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.ContentHubAllowedItemTypeCollection getAllowedItemTypes(String repositoryId, String repositoryFolderId, ConnectApi.ConnectContentHubItemType filter)

Parameters

repositoryId
Type: String
The ID of the repository.
repositoryFolderId
Type: String
The ID of the repository folder.
filter
Type: ConnectApi.ContentHubItemType
Specifies the item types. Values are:
  • Any—Includes files and folders.
  • FilesOnly—Includes files only.
  • FoldersOnly—Includes folders only.

Example

This example calls getAllowedItemTypes(repositoryId, repositoryFolderId, ConnectApi.ContentHubItemType.FilesOnly) to get the first ConnectApi.ContentHubItemTypeSummary.id of a file. The context user can create allowed files in a repository folder in the external system.

1final ConnectApi.ContentHubAllowedItemTypeCollection allowedItemTypesColl = ConnectApi.ContentHub.getAllowedItemTypes(repositoryId, repositoryFolderId, ConnectApi.ContentHubItemType.FilesOnly);
2final List<ConnectApi.ContentHubItemTypeSummary> allowedItemTypes = allowedItemTypesColl.allowedItemTypes;
3string allowedFileItemTypeId = null;
4if(allowedItemTypes.size() > 0){
5   ConnectApi.ContentHubItemTypeSummary allowedItemTypeSummary = allowedItemTypes.get(0);
6   allowedFileItemTypeId = allowedItemTypeSummary.id;
7}

getAllowedItemTypes(communityId, repositoryId, repositoryFolderId)

Get the item types that the context user is allowed to create in the repository folder in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.ContentHubAllowedItemTypeCollection getAllowedItemTypes(String communityId, String repositoryId, String repositoryFolderId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
repositoryId
Type: String
The ID of the repository.
repositoryFolderId
Type: String
The ID of the repository folder.

getAllowedItemTypes(communityId, repositoryId, repositoryFolderId, filter)

Get the item types, filtered by type, that the context user is allowed to create in the repository folder in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.ContentHubAllowedItemTypeCollection getAllowedItemTypes(String communityId, String repositoryId, String repositoryFolderId, ConnectApi.ConnectContentHubItemType filter)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
repositoryId
Type: String
The ID of the repository.
repositoryFolderId
Type: String
The ID of the repository folder.
filter
Type: ConnectApi.ContentHubItemType
Specifies the item types. Values are:
  • Any—Includes files and folders.
  • FilesOnly—Includes files only.
  • FoldersOnly—Includes folders only.

getFilePreview(repositoryId, repositoryFileId, formatType)

Get a repository file preview.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.FilePreview getFilePreview(String repositoryId, String repositoryFileId, ConnectApi.FilePreviewFormat formatType)

Parameters

repositoryId
Type: String
The ID of the repository.
repositoryFileId
Type: String
The ID of the repository file.
formatType
Type: ConnectApi.FilePreviewFormat
Specifies the format of the file preview. Values are:
  • Pdf—Preview format is PDF.
  • Svg—Preview format is compressed SVG.
  • Thumbnail—Preview format is 240 x 180 PNG.
  • ThumbnailBig—Preview format is 720 x 480 PNG.
  • ThumbnailTiny—Preview format is 120 x 90 PNG.
PDF previews are available for files of type DOC, DOCX, PPT, PPTX, TEXT, XLS, and XLSX. SVG files are generated on demand.

Return Value

Type: ConnectApi.FilePreview

Example

This example calls getFilePreview(repositoryId, repositoryFileId, ConnectApi.FilePreviewFormat.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 =
2'document:1-zcA1BaeoQbo2_yNFiHCcK6QJTPmOke-kHFC4TYg3rk';final ConnectApi.FilePreview filePreview =
3ConnectApi.ContentHub.getFilePreview(gDriveRepositoryId, gDriveFileId,
4ConnectApi.FilePreviewFormat.Thumbnail);System.debug(String.format('Preview - URL: \'\'{0}\'\', format: \'\'{1}\'\', nbr of
5renditions for this format: {2}', new String[]{ filePreview.url,
6filePreview.format.name(),String.valueOf(filePreview.previewUrls.size())}));for(ConnectApi.FilePreviewUrl filePreviewUrl : filePreview.previewUrls){
7   System.debug('-----> Rendition URL: ' + filePreviewUrl.previewUrl);
8}

getFilePreview(repositoryId, repositoryFileId, formatType, startPageNumber, endPageNumber)

Get a page or page range of a repository file preview.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.FilePreview getFilePreview(String repositoryId, String repositoryFileId, ConnectApi.FilePreviewFormat formatType, Integer startPageNumber, Integer endPageNumber)

Parameters

repositoryId
Type: String
The ID of the repository.
repositoryFileId
Type: String
The ID of the repository file.
formatType
Type: ConnectApi.FilePreviewFormat
Specifies the format of the file preview. Values are:
  • Pdf—Preview format is PDF.
  • Svg—Preview format is compressed SVG.
  • Thumbnail—Preview format is 240 x 180 PNG.
  • ThumbnailBig—Preview format is 720 x 480 PNG.
  • ThumbnailTiny—Preview format is 120 x 90 PNG.
PDF previews are available for files of type DOC, DOCX, PPT, PPTX, TEXT, XLS, and XLSX. SVG files are generated on demand.
startPageNumber
Type: Integer
The starting page number in the range of file preview URLs.
endPageNumber
Type: Integer
The ending page number in the range of file preview URLs.

Return Value

Type: ConnectApi.FilePreview

getFilePreview(communityId, repositoryId, repositoryFileId, formatType)

Get a repository file preview in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.FilePreview getFilePreview(String communityId, String repositoryId, String repositoryFileId, ConnectApi.FilePreviewFormat formatType)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
repositoryId
Type: String
The ID of the repository.
repositoryFileId
Type: String
The ID of the repository file.
formatType
Type: ConnectApi.FilePreviewFormat
Specifies the format of the file preview. Values are:
  • Pdf—Preview format is PDF.
  • Svg—Preview format is compressed SVG.
  • Thumbnail—Preview format is 240 x 180 PNG.
  • ThumbnailBig—Preview format is 720 x 480 PNG.
  • ThumbnailTiny—Preview format is 120 x 90 PNG.
PDF previews are available for files of type DOC, DOCX, PPT, PPTX, TEXT, XLS, and XLSX. SVG files are generated on demand.

Return Value

Type: ConnectApi.FilePreview

getFilePreview(communityId, repositoryId, repositoryFileId, formatType, startPageNumber, endPageNumber)

Get a page or page range of a repository file preview in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.FilePreview getFilePreview(String communityId, String repositoryId, String repositoryFileId, ConnectApi.FilePreviewFormat formatType, Integer startPageNumber, Integer endPageNumber)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
repositoryId
Type: String
The ID of the repository.
repositoryFileId
Type: String
The ID of the repository file.
formatType
Type: ConnectApi.FilePreviewFormat
Specifies the format of the file preview. Values are:
  • Pdf—Preview format is PDF.
  • Svg—Preview format is compressed SVG.
  • Thumbnail—Preview format is 240 x 180 PNG.
  • ThumbnailBig—Preview format is 720 x 480 PNG.
  • ThumbnailTiny—Preview format is 120 x 90 PNG.
PDF previews are available for files of type DOC, DOCX, PPT, PPTX, TEXT, XLS, and XLSX. SVG files are generated on demand.
startPageNumber
Type: Integer
The starting page number in the range of file preview URLs.
endPageNumber
Type: Integer
The ending page number in the range of file preview URLs.

Return Value

Type: ConnectApi.FilePreview

getItemType(repositoryId, repositoryItemTypeId)

Get information about an item type associated with a repository.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.ContentHubItemTypeDetail getItemType(String repositoryId, String repositoryItemTypeId)

Parameters

repositoryId
Type: String
The ID of the repository.
repositoryItemTypeId
Type: String
The ID of the repository item type.

getItemType(communityId, repositoryId, repositoryItemTypeId)

Get information about an item type associated with a repository in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.ContentHubItemTypeDetail getItemType(String communityId, String repositoryId, String repositoryItemTypeId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
repositoryId
Type: String
The ID of the repository.
repositoryItemTypeId
Type: String
The ID of the repository item type.

getPreviews(repositoryId, repositoryFileId)

Get information about a repository file’s supported previews.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.FilePreviewCollection getPreviews(String repositoryId, String repositoryFileId)

Parameters

repositoryId
Type: String
The ID of the repository.
repositoryFileId
Type: String
The ID of the repository file.

Example

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

getPreviews(communityId, repositoryId, repositoryFileId)

Get information about a repository file’s supported previews in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.FilePreviewCollection getPreviews(String communityId, String repositoryId, String repositoryFileId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
repositoryId
Type: String
The ID of the repository.
repositoryFileId
Type: String
The ID of the repository file.

getRepositories()

Get a list of repositories.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.ContentHubRepositoryCollection getRepositories()

Example

This example gets all repositories and gets the first SharePoint online repository found.

1final string sharePointOnlineProviderType ='ContentHubSharepointOffice365';
2final ConnectApi.ContentHubRepositoryCollection repositoryCollection = ConnectApi.ContentHub.getRepositories();
3ConnectApi.ContentHubRepository sharePointOnlineRepository = null;
4for(ConnectApi.ContentHubRepository repository : repositoryCollection.repositories){
5   if(sharePointOnlineProviderType.equalsIgnoreCase(repository.providerType.type)){
6      sharePointOnlineRepository = repository;
7      break;
8   }
9}

getRepositories(communityId)

Get a list of repositories in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.ContentHubRepositoryCollection getRepositories(String communityId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.

getRepositories(pageParam, pageSize)

Get a page of repositories.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.ContentHubRepositoryCollection getRepositories(Integer pageParam, Integer pageSize)

Parameters

pageParam
Type: Integer
Specifies the number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default page size is 25.

getRepositories(communityId, pageParam, pageSize)

Get a page of repositories in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.ContentHubRepositoryCollection getRepositories(String communityId, Integer pageParam, Integer pageSize)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
pageParam
Type: Integer
Specifies the number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default page size is 25.

getRepository(repositoryId)

Get a repository.

API Version

369.0

Requires Chatter

No

Signature

public static ConnectApi.ContentHubRepository getRepository(String repositoryId)

Parameters

repositoryId
Type: String
The ID of the repository.

Return Value

Type: ConnectApi.ContentHubRepository

Example

1final string repositoryId = '0XCxx0000000123GAA';
2final ConnectApi.ContentHubRepository repository = ConnectApi.ContentHub.getRepository(repositoryId);

getRepository(communityId, repositoryId)

Get a repository in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.ContentHubRepository getRepository(String communityId, String repositoryId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
repositoryId
Type: String
The ID of the repository.

Return Value

Type: ConnectApi.ContentHubRepository

getRepositoryFile(repositoryId, repositoryFileId)

Get a repository file.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFileDetail getRepositoryFile(String repositoryId, String repositoryFileId)

Parameters

repositoryId
Type: String
The ID of the repository.
repositoryFileId
Type: String
The ID of the repository file.

Return Value

Type: ConnectApi.RepositoryFileDetail

Example

1final String gDriveRepositoryId = '0XCxx00000000ODGAY', gDriveFileId = 'file:0B0lTys1KmM3sTmxKNjVJbWZja00';
2final ConnectApi.RepositoryFileDetail file = ConnectApi.ContentHub.getRepositoryFile(gDriveRepositoryId, gDriveFileId);
3System.debug(String.format('File - name: \'\'{0}\'\', size: {1}, external URL: \'\'{2}\'\', download URL: \'\'{3}\'\'', 
4   new String[]{ file.name, String.valueOf(file.contentSize), file.externalDocumentUrl, file.downloadUrl}));

getRepositoryFile(repositoryId, repositoryFileId, includeExternalFilePermissionsInfo)

Get a repository file with or without permissions information.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFileDetail getRepositoryFile(String repositoryId, String repositoryFileId, Boolean includeExternalFilePermissionsInfo)

Parameters

repositoryId
Type: String
The ID of the repository.
repositoryFileId
Type: String
The ID of the repository file.
includeExternalFilePermissionsInfo
Type: Boolean
Specifies whether to include permission information, such as whether the file is shared and what are the available permission types.

Managing external file permissions is supported for Google Drive, SharePoint Online, and OneDrive for Business.

Return Value

Type: ConnectApi.RepositoryFileDetail

Example

1final String gDriveRepositoryId = '0XCxx00000000ODGAY', gDriveFileId = 'file:0B0lTys1KmM3sTmxKNjVJbWZja00';
2
3final ConnectApi.RepositoryFileDetail file = ConnectApi.ContentHub.getRepositoryFile(gDriveRepositoryId, gDriveFileId, true);
4System.debug(String.format('File - name: \'\'{0}\'\', size: {1}, external URL: \'\'{2}\'\', download URL: \'\'{3}\'\'', new String[]{ file.name, String.valueOf(file.contentSize), file.externalDocumentUrl, file.downloadUrl}));
5final ConnectApi.ExternalFilePermissionInformation externalFilePermInfo = file.externalFilePermissionInformation;
6
7//permission types
8final List<ConnectApi.ContentHubPermissionType> permissionTypes = externalFilePermInfo.externalFilePermissionTypes;
9for(ConnectApi.ContentHubPermissionType permissionType : permissionTypes){
10   System.debug(String.format('Permission type - id: \'\'{0}\'\', label: \'\'{1}\'\'', new String[]{ permissionType.id, permissionType.label}));
11}
12
13//permission groups
14final List<ConnectApi.RepositoryGroupSummary> groups = externalFilePermInfo.repositoryPublicGroups;
15for(ConnectApi.RepositoryGroupSummary ggroup : groups){
16   System.debug(String.format('Group - id: \'\'{0}\'\', name: \'\'{1}\'\', type: \'\'{2}\'\'', new String[]{ ggroup.id, ggroup.name, ggroup.type.name()}));
17}

getRepositoryFile(communityId, repositoryId, repositoryFileId)

Get a repository file in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFileDetail getRepositoryFile(String communityId, String repositoryId, String repositoryFileId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
repositoryId
Type: String
The ID of the repository.
repositoryFileId
Type: String
The ID of the repository file.

Return Value

Type: ConnectApi.RepositoryFileDetail

getRepositoryFile(communityId, repositoryId, repositoryFileId, includeExternalFilePermissionsInfo)

Get a repository file with or without permissions information in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFileDetail getRepositoryFile(String communityId, String repositoryId, String repositoryFileId, Boolean includeExternalFilePermissionsInfo)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
repositoryId
Type: String
The ID of the repository.
repositoryFileId
Type: String
The ID of the repository file.
includeExternalFilePermissionsInfo
Type: Boolean
Specifies whether to include permission information, such as whether the file is shared and what are the available permission types.

Managing external file permissions is supported for Google Drive, SharePoint Online, and OneDrive for Business.

Return Value

Type: ConnectApi.RepositoryFileDetail

getRepositoryFolder(repositoryId, repositoryFolderId)

Get a repository folder.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFolderDetail getRepositoryFolder(String repositoryId, String repositoryFolderId)

Parameters

repositoryId
Type: String
The ID of the repository.
repositoryFolderId
Type: String
The ID of the repository folder.

Example

1final String gDriveRepositoryId = '0XCxx00000000ODGAY', gDriveFolderId = 'folder:0B0lTys1KmM3sSVJ2bjIzTGFqSWs';
2final ConnectApi.RepositoryFolderDetail folder = ConnectApi.ContentHub.getRepositoryFolder(gDriveRepositoryId, gDriveFolderId);
3System.debug(String.format('Folder - name: \'\'{0}\'\', description: \'\'{1}\'\', external URL: \'\'{2}\'\', folder items URL: \'\'{3}\'\'', 
4   new String[]{ folder.name, folder.description, folder.externalFolderUrl, folder.folderItemsUrl}));

getRepositoryFolder(communityId, repositoryId, repositoryFolderId)

Get a repository folder in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFolderDetail getRepositoryFolder(String communityId, String repositoryId, String repositoryFolderId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
repositoryId
Type: String
The ID of the repository.
repositoryFolderId
Type: String
The ID of the repository folder.

getRepositoryFolderItems(repositoryId, repositoryFolderId)

Get repository folder items.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFolderItemsCollection getRepositoryFolderItems(String repositoryId, String repositoryFolderId)

Parameters

repositoryId
Type: String
The ID of the repository.
repositoryFolderId
Type: String
The ID of the repository folder.

Example

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

getRepositoryFolderItems(communityId, repositoryId, repositoryFolderId)

Get repository folder items in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFolderItemsCollection getRepositoryFolderItems(String communityId, String repositoryId, String repositoryFolderId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
repositoryId
Type: String
The ID of the repository.
repositoryFolderId
Type: String
The ID of the repository folder.

getRepositoryFolderItems(repositoryId, repositoryFolderId, pageParam, pageSize)

Get a page of repository folder items.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFolderItemsCollection getRepositoryFolderItems(String repositoryId, String repositoryFolderId, Integer pageParam, Integer pageSize)

Parameters

repositoryId
Type: String
The ID of the repository.
repositoryFolderId
Type: String
The ID of the repository folder.
pageParam
Type: Integer
Specifies the number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default page size is 25.

getRepositoryFolderItems(communityId, repositoryId, repositoryFolderId, pageParam, pageSize)

Get a page of repository folder items in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFolderItemsCollection getRepositoryFolderItems(String communityId, String repositoryId, String repositoryFolderId, Integer pageParam, Integer pageSize)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
repositoryId
Type: String
The ID of the repository.
repositoryFolderId
Type: String
The ID of the repository folder.
pageParam
Type: Integer
Specifies the number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default page size is 25.

updateRepositoryFile(repositoryId, repositoryFileId, file)

Update the metadata of a repository file.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFileDetail updateRepositoryFile(String repositoryId, String repositoryFileId, ConnectApi.ContentHubItemInput file)

Parameters

repositoryId
Type: String
The ID of the repository.
repositoryFileId
Type: String
The ID of the repository file.
file
Type: ConnectApi.ContentHubItemInput
The item type ID and fields of the item type.

Return Value

Type: ConnectApi.RepositoryFileDetail

Example

This example updates the metadata of a file in a repository. After the file is updated, we show the file’s ID, name, description, external URL, download URL.
1final String gDriveRepositoryId = '0XCxx00000000ODGAY', gDriveFolderId = 'folder:0B0lTys1KmM3sSVJ2bjIzTGFqSWs', gDriveFileId = 'document:1q9OatVpcyYBK-JWzp_PhR75ulQghwFP15zhkamKrRcQ';
2
3final ConnectApi.ContentHubItemInput updatedItem = new ConnectApi.ContentHubItemInput();
4updatedItem.itemTypeId = 'document'; //see getAllowedTypes for any file item types available for creation/update
5updatedItem.fields = new List<ConnectApi.ContentHubFieldValueInput>();
6
7//Metadata: name field
8final ConnectApi.ContentHubFieldValueInput fieldValueInputName = new ConnectApi.ContentHubFieldValueInput();
9fieldValueInputName.name = 'name';
10fieldValueInputName.value =  'updated file name.txt';
11updatedItem.fields.add(fieldValueInputName);
12
13//Metadata: description field
14final ConnectApi.ContentHubFieldValueInput fieldValueInputNameDesc = new ConnectApi.ContentHubFieldValueInput();
15fieldValueInputNameDesc.name = 'description';
16fieldValueInputNameDesc.value = 'that updates the former description';
17updatedItem.fields.add(fieldValueInputNameDesc);
18
19final ConnectApi.RepositoryFileDetail updatedFile = ConnectApi.ContentHub.updateRepositoryFile(gDriveRepositoryId, gDriveFileId, updatedItem);
20System.debug(String.format('Updated file - id: \'\'{0}\'\', name: \'\'{1}\'\', description: \'\'{2}\'\',\n external URL: \'\'{3}\'\', download URL: \'\'{4}\'\'',  new String[]{ updatedFile.id, updatedFile.name, updatedFile.description, updatedFile.externalDocumentUrl, updatedFile.downloadUrl}));

updateRepositoryFile(repositoryId, repositoryFileId, file, fileData)

Update the content of a repository file.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFileDetail updateRepositoryFile(String repositoryId, String repositoryFileId, ConnectApi.ContentHubItemInput file, ConnectApi.BinaryInput fileData)

Parameters

repositoryId
Type: String
The ID of the repository.
repositoryFileId
Type: String
The ID of the repository file.
file
Type: ConnectApi.ContentHubItemInput
The item type ID and fields of the item type.
fileData
Type: ConnectApi.BinaryInput
The binary file.

Return Value

Type: ConnectApi.RepositoryFileDetail

Example

This example updates the content and metadata of a file in a repository. After the file is updated, we show the file’s ID, name, description, external URL, and download URL.

1final String gDriveRepositoryId = '0XCxx00000000ODGAY', gDriveFolderId = 'folder:0B0lTys1KmM3sSVJ2bjIzTGFqSWs', gDriveFileId = 'document:1q9OatVpcyYBK-JWzp_PhR75ulQghwFP15zhkamKrRcQ';
2
3final ConnectApi.ContentHubItemInput updatedItem = new ConnectApi.ContentHubItemInput();
4updatedItem.itemTypeId = 'document'; //see getAllowedTypes for any file item types available for creation/update
5updatedItem.fields = new List<ConnectApi.ContentHubFieldValueInput>();
6
7//Metadata: name field
8final ConnectApi.ContentHubFieldValueInput fieldValueInputName = new ConnectApi.ContentHubFieldValueInput();
9fieldValueInputName.name = 'name';
10fieldValueInputName.value =  'updated file name.txt';
11updatedItem.fields.add(fieldValueInputName);
12
13//Metadata: description field
14final ConnectApi.ContentHubFieldValueInput fieldValueInputNameDesc = new ConnectApi.ContentHubFieldValueInput();
15fieldValueInputNameDesc.name = 'description';
16fieldValueInputNameDesc.value = 'that updates the former description';
17updatedItem.fields.add(fieldValueInputNameDesc);
18
19//Binary content
20final Blob updatedFileBlob = Blob.valueOf('even more awesome content for updated file');
21final String updatedFileMimeType = 'text/plain';
22final ConnectApi.BinaryInput fileBinaryInput = new ConnectApi.BinaryInput(updatedFileBlob, updatedFileMimeType, updatedFileName);
23
24final ConnectApi.RepositoryFileDetail updatedFile = ConnectApi.ContentHub.updateRepositoryFile(gDriveRepositoryId, gDriveFileId, updatedItem);
25System.debug(String.format('Updated file - id: \'\'{0}\'\', name: \'\'{1}\'\', description: \'\'{2}\'\',\n external URL: \'\'{3}\'\', download URL: \'\'{4}\'\'',  new String[]{ updatedFile.id, updatedFile.name, updatedFile.description, updatedFile.externalDocumentUrl, updatedFile.downloadUrl}));

updateRepositoryFile(communityId, repositoryId, repositoryFileId, file)

Update the metadata of a repository file in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFileDetail updateRepositoryFile(String communityId, String repositoryId, String repositoryFileId, ConnectApi.ContentHubItemInput file)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
repositoryId
Type: String
The ID of the repository.
repositoryFileId
Type: String
The ID of the repository file.
file
Type: ConnectApi.ContentHubItemInput
The item type ID and fields of the item type.

Return Value

Type: ConnectApi.RepositoryFileDetail

updateRepositoryFile(communityId, repositoryId, repositoryFileId, file, fileData)

Update the content of a repository file in a community.

API Version

39.0

Requires Chatter

No

Signature

public static ConnectApi.RepositoryFileDetail updateRepositoryFile(String communityId, String repositoryId, String repositoryFileId, ConnectApi.ContentHubItemInput file, ConnectApi.BinaryInput fileData)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
repositoryId
Type: String
The ID of the repository.
repositoryFileId
Type: String
The ID of the repository file.
file
Type: ConnectApi.ContentHubItemInput
The item type ID and fields of the item type.
fileData
Type: ConnectApi.BinaryInput
The binary file.

Return Value

Type: ConnectApi.RepositoryFileDetail