Newer Version Available
コンテンツを含まないリポジトリファイル (メタデータのみ) の作成
この例では、addRepositoryItem(repositoryId, repositoryFolderId, file) メソッドをコールして、バイナリコンテンツを含まないファイル (メタデータのみの) をリポジトリフォルダに作成します。ファイルを作成した後、ファイルの ID、名前、説明、外部 URL、およびダウンロード 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}));