[SalesForce] Need to pass string of size 100300 in Javascript Remoting function

i am working on a need where in a text file needs which is uploaded, needs to be processed in the controller. We are uploading and displaying the uploaded file in the UI and the same needs to be passed to the controller in the next step.

I am using Java script remoting to pass the file from the UI to the controller. It was all working fine but noticed if i give a file of length greater than 1000000 length i get the below error. Is there a way we can avoid this and pass the file using Remoting.

Visualforce Remoting Exception: Input too long. [0, 1000000]

Below is my snippet

Visualforce.remoting.Manager.invokeAction(
                        '{!$RemoteAction.Translate.RunTranslation}',
                        '{!JSENCODE(sProcessedFile)}', 
                        '{!SourceLanguageName}', 
                        strUser,
                        '{!SourceLanguageCode}',
                       function(result, event){
                                if (event.status) {
                                    jobid = result;
                                    readyProgressbar(result);
                                } 
                                else if (event.type === 'exception') {
                                    alert('Exception 1'+event.message);
                                } 
                            }, 
                            {escape: true}
                        );

Best Answer

There is a very similar question at HTML Input FIle -> Javascript -> to SF Attachment or Richtext Field.

One suggestion there is to switch to using an apex action function instead.

E.g.

Visualforce:

<apex:actionfunction name="af_submitFile" action="{!submitFile}" >
    <apex:param name="fileData" value="" assignTo="{!fileData}"/>
</apex:actionfunction>

Javascript:

af_submitFile(base64EncodedFile);

Apex Controller:

public string fileData {get;set;}

public void submitFile(){

    Blob fileDataBlob = blob.valueOf(imageData);
    // Do something with the file
}