3

I want to make a ContentVersion record publicly available using Apex.

I know I can get the DistributionPublicUrl value from the ContentDistribution object.

But I don't know how I should configure the ContentVersion so that the DistributionPublicUrl is generated?

1 Answer 1

6

Just create an instance of ContentDistribution by providing you ContentVersion and a Name and then query the DistributionPublicUrl.

ContentDistribution cdl = new ContentDistribution();
cdl.ContentVersionId = '0680DXXX002RmxQAE';
cdl.Name = 'PublicShare';
insert cdl;

cdl = [SELECT DistributionPublicUrl FROM ContentDistribution WHERE Id = :cdl.Id LIMIT 1];
return cdl.DistributionPublicUrl;

Reference:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .