I have a string which has a length of 89308
which represents a PDF document.
I want to store this data into a ContentVersion
like this:
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 ContentVersion
record 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 89308
characters.
And the Field Reference for ContentVersion does not state a limit.
Questions
- How can I get around this DML insert limitation such that I can store the content?
Body__c
. Do you have a trigger involved that might be copying the content to another sObject? What's the full stack trace?ContentVersion
. I will add more stack trace.