I have a string which has a length of
89308which represents a PDF document.
I want to store this data into a
ContentVersion contentVersion = new ContentVersion( versionData = Blob.valueOf(label), title = 'PDF Label', pathOnClient = '/Label-' + DateTime.now().getTime() + '.pdf', FirstPublishLocationId = relatedID); insert contentVersion;
But when I insert the
ContentVersionrecord I get this error:
System.DmlException: Insert failed. First exception on row 2; first error: STRING_TOO_LONG, Body: data value too large: … (max length=32768): [Body__c]
But if I look at the SOAP API reference for ContentVersion it says:
The maximum file size you can upload via the SOAP API is 50 MB.
Which means I can store a lot more than
And the Field Reference for ContentVersion does not state a limit.
- How can I get around this DML insert limitation such that I can store the content?
@DavidReed made the key break through – by noticing that the error related to
After storing the data into the
ContentVersion I was logging the REST request into another object which had a field
Body__c which had a max length of
32768, and this was throwing the exception.
Because the content being stored into the
ContentVersion and the Log was identical, I did not realise.