Images from Files
/* Getting ContentVersion file using ContentDocument Id */
ContentVersion file = [SELECT Id, Title FROM ContentVersion WHERE ContentDocumentId = '<Content Document ID>'].Id;
/* Creating ContentDistribution record */
insert new ContentDistribution(
Name = file.Title,
ContentVersionId = file.Id,
PreferencesAllowViewInBrowser= true
);Last updated
Was this helpful?

