この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

Newer Version Available

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

コンテンツを含むリポジトリファイルの更新

この例では、updateRepositoryFile(repositoryId, repositoryFileId, file, fileData) をコールして、リポジトリ内のファイルの内容とメタデータを更新します。ファイルを更新した後、ファイルの ID、名前、説明、外部 URL、およびダウンロード 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//Binary content
14final Blob updatedFileBlob = Blob.valueOf('even more awesome content for updated file');
15final String updatedFileMimeType = 'text/plain';
16final ConnectApi.BinaryInput fileBinaryInput = new ConnectApi.BinaryInput(updatedFileBlob, updatedFileMimeType, updatedFileName);
17
18final ConnectApi.RepositoryFileDetail updatedFile = ConnectApi.ContentHub.updateRepositoryFile(gDriveRepositoryId, gDriveFileId, updatedItem);
19System.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}));