0

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.

2
  • public ContentVersion conVer {get; set;} private static final Integer IMAGE_MAX_SIZE = 1048576; if (conVer.ContentSize > IMAGE_MAX_SIZE) { do } But it's not worked Sep 27 '18 at 10:50
  • if (conVer.FileExtension == 'jpg') { do } It's not worked too Sep 27 '18 at 10:52
1

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.