function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
crop1645crop1645 

Internal server error - inputFile - SOLVED

Scenario:

 

  1. VF Controller Extension interacting with a VF page containing an inputFile component.
  2. User fills in form; including filename
  3. User clicks commandButton that calls action method on VF controller
  4. Validation rules within action method execute within context of try - DML statements - catch block
  5. Errors caught and set on page via Apexpages.addMessage(...) method call
  6. SFDC displays page with Internal Server Error !?!

Solution in succeeding post

Best Answer chosen by Admin (Salesforce Developers) 
crop1645crop1645

OK, here's the solution

 

The error is because the view state size is exceeded through holding onto the inputFile value attribute between the commandbutton action and the page redisplay with validation errors.  The VF viewstate size is 128KB.  In some file upload cases (like mine), your upload file will be more than 128KB (like uploading PDFs).

 

In your VF controller, change your variable that holds the inputFile Blob from:

 

public Blob fileBody {get; set;}

to:

 

public transient Blob fileBody {get; set;}

 and Bob's your uncle.