0

I have a requirement to upload the csv file of 12mb and read the content in it. Through Lightningfile upload component i am able to load the file in Salesofrce Files and here is the below link for that. https://developer.salesforce.com/docs/component-library/bundle/lightning:fileUpload/documentation

Now i am facing an issue of reading the file from Apex. While converting versiondata of content version it is throwing the below error. System.StringException: String length exceeds maximum: 6000000

Any help on resolving this issue will be more helpful.

1

You can't process 12 MB worth of CSV in Apex. As you've found, Strings can't be longer than 6,000,000 characters. Besides this, Apex is not particularly well-suited to parsing files, and most CSV implementations I've seen are unacceptably unreliable.

The largest heap size limit you'll get in Apex code (other than an email service) is 12 MB, in any case. See the limits documentation. If you're processing a 12 MB CSV, that leaves no room for data that's been processed, making it extremely unlikely that you would be able to successfully complete that operation.

Process the CSV in browser-side JavaScript instead, where you can take advantage of existing libraries for working with CSV data. Then, make calls with reasonably batched-out data into your Apex code to persist records.

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.