ContentVersion works very different from Attachment Object.
When you have a trigger on it for before insert, You will get these value in trigger.new:-
ContentVersion:{Id=null, ContentDocumentId=null, IsLatest=false, ContentUrl=null, ContentBodyId=05TB000000AUAAuMAP, VersionNumber=null, Title=Capture, Description=null, ReasonForChange=null, SharingOption=A, SharingPrivacy=N, PathOnClient=Capture.PNG, RatingCount=0, IsDeleted=false, ContentModifiedDate=null, ContentModifiedById=null, PositiveRatingCount=0, NegativeRatingCount=0, FeaturedContentBoost=null,
FeaturedContentDate=null, OwnerId=005B0000005htWrIAI, CreatedById=005B0000005htWrIAI, CreatedDate=2019-07-06 03:49:08, LastModifiedById=null, LastModifiedDate=null, SystemModstamp=null, TagCsv=null, FileType=null, PublishStatus=U, VersionData=null, ContentSize=0, FileExtension=null,
FirstPublishLocationId=005B0000005htWrIAI, Origin=C, NetworkId=null, ContentLocation=S, TextPreview=null, ExternalDocumentInfo1=null, ExternalDocumentInfo2=null, ExternalDataSourceId=null, Checksum=null, IsMajorVersion=false, IsAssetEnabled=false}
On After Insert, You Will get these values:-
DEBUG|ContentVersion:{Id=068B0000005kZ0cIAE, ContentDocumentId=069B0000005gBgSIAU, IsLatest=true, ContentUrl=null, ContentBodyId=05TB000000AUAAzMAP, VersionNumber=1, Title=download, Description=null, ReasonForChange=null, SharingOption=A, SharingPrivacy=N, PathOnClient=download.jpg, RatingCount=0, IsDeleted=false,
ContentModifiedDate=2019-07-06 03:52:14, ContentModifiedById=005B0000005htWrIAI, PositiveRatingCount=0, NegativeRatingCount=0, FeaturedContentBoost=null, FeaturedContentDate=null, OwnerId=005B0000005htWrIAI, CreatedById=005B0000005htWrIAI, CreatedDate=2019-07-06 03:52:14, LastModifiedById=005B0000005htWrIAI,
LastModifiedDate=2019-07-06 03:52:14, SystemModstamp=2019-07-06 03:52:14, TagCsv=null, FileType=JPG, PublishStatus=R, VersionData=null, ContentSize=8301, FileExtension=null, FirstPublishLocationId=005B0000005htWrIAI, Origin=C, NetworkId=null, ContentLocation=S,
TextPreview=null, ExternalDocumentInfo1=null, ExternalDocumentInfo2=null, ExternalDataSourceId=null, Checksum=null, IsMajorVersion=false, IsAssetEnabled=false}
In both the case, VersionData where the body of the file gets stored are null. You have to do an extra query to get the VersionData.
Note:- ContentDocument and ContentDcumentLink does not have
versionData Field. So no use of writing a trigger on them.
Also, The only value that gets updated in the Apex instance for any SObject when you insert is the Id value. Other fields populated as part of the insert by triggers or other logic have to be re-queried to get the values - ContentVersion
is no different.
Refer my this question:- ContentDocumentID is not available just after ContentVersion getting inserted But available after soql query