1 answer
You need to add a trigger on the "ContentVersion" object so that a "ContentDocumentLink" gets created. This represents a file sharing record.
A rough, non-bulkified version that just handles a single user would be:trigger ContentVersionTrigger on ContentVersion (after insert) {
insert new ContentDocumentLink(
ContentDocumentId = trigger.new[0].ContentDocumentId,
LinkedEntityId = '<a user id>',
ShareType = 'C',
Visibility = 'AllUsers'
);
}
See the docs (
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentdocumentlink.htm) for more information on ContentDocumentLink