[SalesForce] ContentVersion: how to check File Type and File Size

I need to check Max Image Size and File Type so I can display the correct error in ApexPages.Messages. I tried to do something like this:

if (conVer.FileType != '')

But I don't know what FileType values I can use.

Best Answer

You can use values like "WORD_X" or "PDF" or etc. The easiest way I've found is to upload a file, and then check the FileExtension field on ContentVersion or ContentDocument.

More details here:

https://developer.salesforce.com/docs/atlas.en-us.sfFieldRef.meta/sfFieldRef/salesforce_field_reference_ContentDocument.htm