Salesforceファイルと各オブジェクトのレコードに紐付け

//ファイルIDはKEY、オブジェクトIDはValue
Map<String, String> filesMap = new Map<String, String>();
/**既存ファイルのMAPを作成**/
filesMap.put(1, 'First item');
filesMap.put(2, 'Second item');

List<ContentDocumentLink> conDocLinkRecs = new List<ContentDocumentLink>();

for(String idKey : filesMap.keySet()){
    // コンテンツドキュメントリンクを保存する
    ContentDocumentLink conDocLink = new ContentDocumentLink();
    conDocLink.ContentDocumentId = idKey;//ファイル自体のリンクID
    conDocLink.LinkedEntityId = filesMap.get(idKey); // リンクしたオブジェクトの ID
    System.debug('------ContentDocumentId---->'+idKey);
    System.debug('------LinkedEntityId---->'+filesMap.get(idKey));
    conDocLink.ShareType = 'I'; // 推定権限。ユーザの権限は関連するレコードによって決まります。
    conDocLink.Visibility = 'AllUsers'; // このファイルは、このファイルを参照する権限を持つすべてのユーザが使用できます。
    conDocLinkRecs.add(conDocLink);
}
insert conDocLinkRecs;