0

I'm trying to upload a csv file from VF page. I'm using the inputFile component within apex:Form tags, and using blob data type in controller class and then converting it to string. The problem I'm facing: I get "Maximum view state size limit exceeded" error. It is because my csv file size is around 400KB. Is there any workaround? I've tried uploading the csv as a file in document object but cannot figure out how to read the data from this document file.

Can anyone please let me know how to read the csv file using document class methods or, any other way to read the csv file records (using VF page).

Thanks!

1

This happens because the "view state" happens to be limited to only 135kb. Typically, when you're uploading files, you need to remember that you can't store files in the view state. Instead, mark the file data as transient:

public transient Blob fileBody { get; set; }

This means the file's contents will not persist between transactions. It also means users will need to re-select the file if something goes wrong. If you want to avoid having users re-upload the file, save the data to a record (perhaps a Document or Attachment).

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.