Call a method to create a file without binary content (metadata only) in a Google Drive
repository folder.
Call addRepositoryItem(repositoryId, repositoryFolderId, file) to create a
file without binary content (metadata only) in a Google Drive repository folder. After the
file is created, we show the file’s ID, name, description, external URL, and download
URL.
final String gDriveRepositoryId = '0XCxx00000000ODGAY', gDriveFolderId = 'folder:0B0lTys1KmM3sSVJ2bjIzTGFqSWs'; final ConnectApi.ContentHubItemInput newItem = new ConnectApi.ContentHubItemInput(); newItem.itemTypeId = 'document'; //see getAllowedTypes for any file item types available for creation/update newItem.fields = new List<ConnectApi.ContentHubFieldValueInput>(); //Metadata: name field final ConnectApi.ContentHubFieldValueInput fieldValueInput = new ConnectApi.ContentHubFieldValueInput(); fieldValueInput.name = 'name'; fieldValueInput.value = 'new folder item name.txt'; newItem.fields.add(fieldValueInput); //Metadata: description field final ConnectApi.ContentHubFieldValueInput fieldValueInputDesc = new ConnectApi.ContentHubFieldValueInput(); fieldValueInputDesc.name = 'description'; fieldValueInputDesc.value = 'It does describe it'; newItem.fields.add(fieldValueInputDesc); final ConnectApi.RepositoryFolderItem newFolderItem = ConnectApi.ContentHub.addRepositoryItem(gDriveRepositoryId, gDriveFolderId, newItem); final ConnectApi.RepositoryFileSummary newFile = newFolderItem.file; System.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}));